init
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { IServerResponse } from '@/types/common.types';
|
||||
import { API_BASE_URL } from '@/shared/constants';
|
||||
import apiClient from '@api/api-client';
|
||||
import { ITaskLabel } from '@/types/tasks/taskLabel.types';
|
||||
|
||||
const rootUrl = `${API_BASE_URL}/labels`;
|
||||
|
||||
export const labelsApiService = {
|
||||
getLabels: async (): Promise<IServerResponse<ITaskLabel[]>> => {
|
||||
const response = await apiClient.get<IServerResponse<ITaskLabel[]>>(`${rootUrl}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
getPriorityByTask: async (taskId: string): Promise<IServerResponse<ITaskLabel[]>> => {
|
||||
const response = await apiClient.get<IServerResponse<ITaskLabel[]>>(
|
||||
`${rootUrl}/tasks/${taskId}`
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
getPriorityByProject: async (projectId: string): Promise<IServerResponse<ITaskLabel[]>> => {
|
||||
const response = await apiClient.get<IServerResponse<ITaskLabel[]>>(
|
||||
`${rootUrl}/project/${projectId}`
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
updateColor: async (labelId: string, color: string): Promise<IServerResponse<ITaskLabel>> => {
|
||||
const response = await apiClient.put<IServerResponse<ITaskLabel>>(
|
||||
`${rootUrl}/tasks/${labelId}/color`,
|
||||
{ color }
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
deleteById: async (labelId: string): Promise<IServerResponse<void>> => {
|
||||
const response = await apiClient.delete<IServerResponse<void>>(`${rootUrl}/team/${labelId}`);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
import apiClient from '@/api/api-client';
|
||||
import { API_BASE_URL } from '@/shared/constants';
|
||||
import { IServerResponse } from '@/types/common.types';
|
||||
import { ITaskPhase } from '@/types/tasks/taskPhase.types';
|
||||
import { toQueryString } from '@/utils/toQueryString';
|
||||
|
||||
const rootUrl = `${API_BASE_URL}/task-phases`;
|
||||
|
||||
interface UpdateSortOrderBody {
|
||||
from_index: number;
|
||||
to_index: number;
|
||||
phases: ITaskPhase[];
|
||||
project_id: string;
|
||||
}
|
||||
|
||||
export const phasesApiService = {
|
||||
addPhaseOption: async (projectId: string) => {
|
||||
const q = toQueryString({ id: projectId, current_project_id: projectId });
|
||||
const response = await apiClient.post<IServerResponse<ITaskPhase>>(`${rootUrl}${q}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
getPhasesByProjectId: async (projectId: string) => {
|
||||
const q = toQueryString({ id: projectId });
|
||||
const response = await apiClient.get<IServerResponse<ITaskPhase[]>>(`${rootUrl}${q}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
deletePhaseOption: async (phaseOptionId: string, projectId: string) => {
|
||||
const q = toQueryString({ id: projectId, current_project_id: projectId });
|
||||
const response = await apiClient.delete<IServerResponse<ITaskPhase>>(
|
||||
`${rootUrl}/${phaseOptionId}${q}`
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
updatePhaseColor: async (projectId: string, body: ITaskPhase) => {
|
||||
const q = toQueryString({ id: projectId, current_project_id: projectId });
|
||||
const response = await apiClient.put<IServerResponse<ITaskPhase>>(
|
||||
`${rootUrl}/change-color/${body.id}${q}`,
|
||||
body
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
updateNameOfPhase: async (phaseId: string, body: ITaskPhase, projectId: string,) => {
|
||||
const q = toQueryString({ id: projectId, current_project_id: projectId });
|
||||
const response = await apiClient.put<IServerResponse<ITaskPhase>>(
|
||||
`${rootUrl}/${phaseId}${q}`,
|
||||
body
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
updatePhaseOrder: async (projectId: string, body: UpdateSortOrderBody) => {
|
||||
const q = toQueryString({ id: projectId, current_project_id: projectId });
|
||||
const response = await apiClient.put<IServerResponse<ITaskPhase[]>>(
|
||||
`${rootUrl}/update-sort-order${q}`,
|
||||
body
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
updateProjectPhaseLabel: async (projectId: string, phaseLabel: string) => {
|
||||
const q = toQueryString({ id: projectId, current_project_id: projectId });
|
||||
const response = await apiClient.put<IServerResponse<ITaskPhase>>(
|
||||
`${rootUrl}/label/${projectId}${q}`,
|
||||
{ name: phaseLabel }
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
import { IServerResponse } from '@/types/common.types';
|
||||
import { API_BASE_URL } from '@/shared/constants';
|
||||
import { ITaskPrioritiesGetResponse, ITaskPriority } from '@/types/tasks/taskPriority.types';
|
||||
import apiClient from '@api/api-client';
|
||||
|
||||
const rootUrl = `${API_BASE_URL}/task-priorities`;
|
||||
|
||||
export const priorityApiService = {
|
||||
getPriorities: async (): Promise<IServerResponse<ITaskPrioritiesGetResponse[]>> => {
|
||||
const response = await apiClient.get<IServerResponse<ITaskPrioritiesGetResponse[]>>(
|
||||
`${rootUrl}`
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
getPriorityById: async (priorityId: string): Promise<IServerResponse<ITaskPriority>> => {
|
||||
const response = await apiClient.get<IServerResponse<ITaskPriority>>(
|
||||
`${rootUrl}/${priorityId}`
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
import { IServerResponse } from '@/types/common.types';
|
||||
import apiClient from '@api/api-client';
|
||||
import { API_BASE_URL } from '@/shared/constants';
|
||||
import { ITaskStatus, ITaskStatusCategory } from '@/types/status.types';
|
||||
import { ITaskStatusCreateRequest } from '@/types/tasks/task-status-create-request';
|
||||
import { toQueryString } from '@/utils/toQueryString';
|
||||
import { ITaskStatusUpdateModel } from '@/types/tasks/task-status-update-model.types';
|
||||
|
||||
const rootUrl = `${API_BASE_URL}/statuses`;
|
||||
|
||||
export const statusApiService = {
|
||||
getStatuses: async (projectId: string): Promise<IServerResponse<ITaskStatus[]>> => {
|
||||
const response = await apiClient.get<IServerResponse<ITaskStatus[]>>(
|
||||
`${rootUrl}?project=${projectId}`
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
getStatusCategories: async (): Promise<IServerResponse<ITaskStatusCategory[]>> => {
|
||||
const response = await apiClient.get<IServerResponse<ITaskStatusCategory[]>>(
|
||||
`${rootUrl}/categories`
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
createStatus: async (
|
||||
body: ITaskStatusCreateRequest,
|
||||
currentProjectId: string
|
||||
): Promise<IServerResponse<ITaskStatus>> => {
|
||||
const q = toQueryString({ current_project_id: currentProjectId });
|
||||
const response = await apiClient.post<IServerResponse<ITaskStatus>>(`${rootUrl}${q}`, body);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
updateStatus: async (
|
||||
statusId: string,
|
||||
body: ITaskStatusUpdateModel,
|
||||
currentProjectId: string
|
||||
): Promise<IServerResponse<ITaskStatus>> => {
|
||||
const q = toQueryString({ current_project_id: currentProjectId });
|
||||
|
||||
const response = await apiClient.put<IServerResponse<ITaskStatus>>(
|
||||
`${rootUrl}/${statusId}${q}`,
|
||||
body
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
updateNameOfStatus: async (
|
||||
id: string,
|
||||
body: ITaskStatusUpdateModel,
|
||||
currentProjectId: string
|
||||
): Promise<IServerResponse<ITaskStatus>> => {
|
||||
const q = toQueryString({ current_project_id: currentProjectId });
|
||||
|
||||
const response = await apiClient.put<IServerResponse<ITaskStatus>>(
|
||||
`${rootUrl}/name/${id}${q}`,
|
||||
body
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
updateStatusOrder: async (
|
||||
body: ITaskStatusCreateRequest,
|
||||
currentProjectId: string
|
||||
): Promise<IServerResponse<ITaskStatus>> => {
|
||||
const q = toQueryString({ current_project_id: currentProjectId });
|
||||
const response = await apiClient.put<IServerResponse<ITaskStatus>>(`${rootUrl}/order`, body);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
deleteStatus: async (statusId: string, projectId: string, replacingStatusId: string): Promise<IServerResponse<void>> => {
|
||||
const q = toQueryString({ project: projectId, current_project_id: projectId, replace: replacingStatusId || null });
|
||||
const response = await apiClient.delete<IServerResponse<void>>(`${rootUrl}/${statusId}${q}`);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user