This commit is contained in:
chamikaJ
2025-04-17 18:28:54 +05:30
parent f583291d8a
commit 8825b0410a
2837 changed files with 241385 additions and 127578 deletions

View File

@@ -0,0 +1,54 @@
import { IServerResponse } from '@/types/common.types';
import { API_BASE_URL } from '@/shared/constants';
import { IProjectCategory, IProjectCategoryViewModel } from '@/types/project/projectCategory.types';
import apiClient from '@api/api-client';
const rootUrl = `${API_BASE_URL}/project-categories`;
export const categoriesApiService = {
getCategories: async (): Promise<IServerResponse<IProjectCategoryViewModel[]>> => {
const response = await apiClient.get<IServerResponse<IProjectCategoryViewModel[]>>(rootUrl);
return response.data;
},
getCategoriesByTeam: async (
id: string
): Promise<IServerResponse<IProjectCategoryViewModel[]>> => {
const response = await apiClient.get<IServerResponse<IProjectCategoryViewModel[]>>(
`${rootUrl}/${id}`
);
return response.data;
},
getCategoriesByOrganization: async (): Promise<IServerResponse<IProjectCategoryViewModel[]>> => {
const response = await apiClient.get<IServerResponse<IProjectCategoryViewModel[]>>(
`${rootUrl}/org-categories`
);
return response.data;
},
createCategory: async (
category: Partial<IProjectCategory>
): Promise<IServerResponse<IProjectCategoryViewModel>> => {
const response = await apiClient.post<IServerResponse<IProjectCategoryViewModel>>(
rootUrl,
category
);
return response.data;
},
updateCategory: async (
category: IProjectCategoryViewModel
): Promise<IServerResponse<IProjectCategoryViewModel>> => {
const response = await apiClient.put<IServerResponse<IProjectCategoryViewModel>>(
`${rootUrl}/${category.id}`,
category
);
return response.data;
},
deleteCategory: async (id: string): Promise<IServerResponse<string>> => {
const response = await apiClient.delete<IServerResponse<string>>(`${rootUrl}/${id}`);
return response.data;
},
};

View File

@@ -0,0 +1,44 @@
import apiClient from '@api/api-client';
import { API_BASE_URL } from '@/shared/constants';
import { IServerResponse } from '@/types/common.types';
import { IJobTitle, IJobTitlesViewModel } from '@/types/job.types';
import { toQueryString } from '@/utils/toQueryString';
const rootUrl = `${API_BASE_URL}/job-titles`;
export const jobTitlesApiService = {
async getJobTitles(
index: number,
size: number,
field: string | null,
order: string | null,
search?: string | null
): Promise<IServerResponse<IJobTitlesViewModel>> {
const s = encodeURIComponent(search || '');
const queryString = toQueryString({ index, size, field, order, search: s });
const response = await apiClient.get<IServerResponse<IJobTitlesViewModel>>(
`${rootUrl}${queryString}`
);
return response.data;
},
async getJobTitleById(id: string): Promise<IServerResponse<IJobTitle>> {
const response = await apiClient.get<IServerResponse<IJobTitle>>(`${rootUrl}/${id}`);
return response.data;
},
async createJobTitle(body: IJobTitle): Promise<IServerResponse<IJobTitle>> {
const response = await apiClient.post<IServerResponse<IJobTitle>>(rootUrl, body);
return response.data;
},
async updateJobTitle(id: string, body: IJobTitle): Promise<IServerResponse<IJobTitle>> {
const response = await apiClient.put<IServerResponse<IJobTitle>>(`${rootUrl}/${id}`, body);
return response.data;
},
async deleteJobTitle(id: string): Promise<IServerResponse<void>> {
const response = await apiClient.delete<IServerResponse<void>>(`${rootUrl}/${id}`);
return response.data;
},
};

View File

@@ -0,0 +1,39 @@
import apiClient from '@api/api-client';
import { API_BASE_URL } from '@/shared/constants';
import { IServerResponse } from '@/types/common.types';
import { ITaskLabel } from '@/types/label.type';
import { toQueryString } from '@/utils/toQueryString';
const rootUrl = `${API_BASE_URL}/labels`;
export const labelsApiService = {
getLabels: async (projectId: string | null = null): Promise<IServerResponse<ITaskLabel>> => {
const q = toQueryString({ project: projectId });
const response = await apiClient.get<IServerResponse<ITaskLabel>>(`${rootUrl}${q}`);
return response.data;
},
getLabelsByTaskId: async (taskId: string): Promise<IServerResponse<ITaskLabel>> => {
const response = await apiClient.get<IServerResponse<ITaskLabel>>(`${rootUrl}/tasks/${taskId}`);
return response.data;
},
getByProjectId: async (projectId: string): Promise<IServerResponse<ITaskLabel>> => {
const response = await apiClient.get<IServerResponse<ITaskLabel>>(
`${rootUrl}/project/${projectId}`
);
return response.data;
},
updateColor: async (id: string, color: string): Promise<IServerResponse<ITaskLabel>> => {
const response = await apiClient.put<IServerResponse<ITaskLabel>>(`${rootUrl}/tasks/${id}`, {
color,
});
return response.data;
},
deleteLabel: async (id: string): Promise<IServerResponse<void>> => {
const response = await apiClient.delete<IServerResponse<void>>(`${rootUrl}/${id}`);
return response.data;
},
};

View File

@@ -0,0 +1,18 @@
import { API_BASE_URL } from '@/shared/constants';
import { IServerResponse } from '@/types/common.types';
import { ITimezone } from '@/types/settings/timezone.types';
import apiClient from '@api/api-client';
const rootUrl = `${API_BASE_URL}/timezones`;
export const timezonesApiService = {
update: async <T>(body: any): Promise<IServerResponse<ITimezone[]>> => {
const response = await apiClient.put<IServerResponse<ITimezone[]>>(rootUrl, body);
return response.data;
},
get: async <T>(): Promise<IServerResponse<ITimezone[]>> => {
const response = await apiClient.get<IServerResponse<ITimezone[]>>(rootUrl);
return response.data;
},
};

View File

@@ -0,0 +1,71 @@
import apiClient from '@api/api-client';
import { API_BASE_URL } from '@/shared/constants';
import { IServerResponse } from '@/types/common.types';
import { IProfileSettings } from '@/types/settings/profile.types';
import { INotificationSettings } from '@/types/settings/notifications.types';
import {
IAccountSetupRequest,
IAccountSetupResponse,
} from '@/types/project-templates/project-templates.types';
import { ITeam } from '@/types/teams/team.type';
const rootUrl = `${API_BASE_URL}/settings`;
export const profileSettingsApiService = {
getProfile: async (): Promise<IServerResponse<IProfileSettings>> => {
const response = await apiClient.get<IServerResponse<IProfileSettings>>(`${rootUrl}/profile`);
return response.data;
},
updateProfile: async (body: IProfileSettings): Promise<IServerResponse<IProfileSettings>> => {
const response = await apiClient.put<IServerResponse<IProfileSettings>>(
`${rootUrl}/profile`,
body
);
return response.data;
},
getNotificationSettings: async (): Promise<IServerResponse<INotificationSettings>> => {
const response = await apiClient.get<IServerResponse<INotificationSettings>>(
`${rootUrl}/notifications`
);
return response.data;
},
updateNotificationSettings: async (
body: INotificationSettings
): Promise<IServerResponse<INotificationSettings>> => {
const response = await apiClient.put<IServerResponse<INotificationSettings>>(
`${rootUrl}/notifications`,
body
);
return response.data;
},
setupAccount: async (
body: IAccountSetupRequest
): Promise<IServerResponse<IAccountSetupResponse>> => {
const response = await apiClient.post<IServerResponse<IAccountSetupResponse>>(
`${rootUrl}/setup`,
body
);
return response.data;
},
updateTeamName: async (id: string, body: ITeam): Promise<IServerResponse<ITeam>> => {
const response = await apiClient.put<IServerResponse<ITeam>>(`${rootUrl}/team-name/${id}`, body);
return response.data;
},
changePassword: async (body: {
new_password: string;
confirm_password: string;
password: string;
}): Promise<IServerResponse<any>> => {
const response = await apiClient.post<IServerResponse<any>>(
`${API_BASE_URL}/change-password`,
body
);
return response.data;
},
};