feat(tags): Test case tag editing UI and tag settings UI (#322)

This commit is contained in:
Eliezer Castro
2025-11-02 04:52:15 -03:00
committed by GitHub
parent b71f3e99cc
commit 3fd226bdbd
21 changed files with 896 additions and 143 deletions

View File

@@ -0,0 +1,28 @@
import { logError } from './errorHandler';
import Config from '@/config/config';
const apiServer = Config.apiServer;
export async function updateCaseTags(jwt: string, caseId: number, tagIds: number[], projectId: string) {
const fetchOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${jwt}`,
},
body: JSON.stringify({ tagIds }),
};
const url = `${apiServer}/casetags/update?projectId=${projectId}?&caseId=${caseId}`;
try {
const response = await fetch(url, fetchOptions);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
return data || [];
} catch (error: unknown) {
logError('Error updating case tags:', error);
}
}

View File

@@ -0,0 +1,104 @@
import { logError } from './errorHandler';
import Config from '@/config/config';
const apiServer = Config.apiServer;
async function fetchTags(jwt: string, projectId: string) {
const fetchOptions = {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${jwt}`,
},
};
const url = `${apiServer}/tags?projectId=${projectId}`;
try {
const response = await fetch(url, fetchOptions);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
return data || [];
} catch (error: unknown) {
logError('Error fetching case tags', error);
}
}
async function createTag(jwt: string, projectId: string, tagName: string) {
const fetchOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${jwt}`,
},
body: JSON.stringify({ name: tagName }),
};
const url = `${apiServer}/tags?projectId=${projectId}`;
try {
const response = await fetch(url, fetchOptions);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
return data;
} catch (error: unknown) {
logError('Error creating case tag', error);
throw error;
}
}
async function updateTag(jwt: string, projectId: string, tagId: number, tagName: string) {
const fetchOptions = {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${jwt}`,
},
body: JSON.stringify({ name: tagName }),
};
const url = `${apiServer}/tags/${tagId}?projectId=${projectId}`;
try {
const response = await fetch(url, fetchOptions);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
return data;
} catch (error: unknown) {
logError('Error updating case tag', error);
throw error;
}
}
async function deleteTag(jwt: string, projectId: string, tagId: number) {
const fetchOptions = {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${jwt}`,
},
};
const url = `${apiServer}/tags/${tagId}?projectId=${projectId}`;
try {
const response = await fetch(url, fetchOptions);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
} catch (error: unknown) {
logError('Error deleting case tag', error);
throw error;
}
}
export { fetchTags, createTag, updateTag, deleteTag };