mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 06:00:55 +00:00
125 lines
3.4 KiB
TypeScript
125 lines
3.4 KiB
TypeScript
import { hrApi } from "@/auth/http";
|
|
import type {
|
|
Appraisal,
|
|
AppraisalCycle,
|
|
AppraisalGoal,
|
|
AppraisalStatus,
|
|
AppraisalTemplate,
|
|
} from "./types";
|
|
|
|
interface Page<T> {
|
|
items: T[];
|
|
total: number;
|
|
page: number;
|
|
pageCount: number;
|
|
}
|
|
|
|
export const listTemplates = async (): Promise<AppraisalTemplate[]> => {
|
|
const response = await hrApi.get<AppraisalTemplate[]>("/appraisal/templates");
|
|
return response.data;
|
|
};
|
|
|
|
export const createTemplate = async (payload: Record<string, unknown>) => {
|
|
const response = await hrApi.post<AppraisalTemplate>(
|
|
"/appraisal/templates",
|
|
payload,
|
|
);
|
|
return response.data;
|
|
};
|
|
|
|
export const listCycles = async (): Promise<AppraisalCycle[]> => {
|
|
const response = await hrApi.get<AppraisalCycle[]>("/appraisal/cycles");
|
|
return response.data;
|
|
};
|
|
|
|
export const createCycle = async (payload: Record<string, unknown>) => {
|
|
const response = await hrApi.post<AppraisalCycle>("/appraisal/cycles", payload);
|
|
return response.data;
|
|
};
|
|
|
|
export const openCycle = async (id: string, employeeIds?: string[]) => {
|
|
const response = await hrApi.post<{
|
|
cycle: AppraisalCycle;
|
|
created: number;
|
|
skipped: number;
|
|
}>(`/appraisal/cycles/${id}/open`, { employeeIds });
|
|
return response.data;
|
|
};
|
|
|
|
export const closeCycle = async (id: string) => {
|
|
const response = await hrApi.patch<AppraisalCycle>(
|
|
`/appraisal/cycles/${id}/close`,
|
|
);
|
|
return response.data;
|
|
};
|
|
|
|
export const getCycleProgress = async (id: string) => {
|
|
const response = await hrApi.get<Record<string, number>>(
|
|
`/appraisal/cycles/${id}/progress`,
|
|
);
|
|
return response.data;
|
|
};
|
|
|
|
export const getMyAppraisals = async (): Promise<Appraisal[]> => {
|
|
const response = await hrApi.get<Appraisal[]>("/appraisal/mine");
|
|
return response.data;
|
|
};
|
|
|
|
export const getAwaitingMe = async (): Promise<Appraisal[]> => {
|
|
const response = await hrApi.get<Appraisal[]>("/appraisal/awaiting-me");
|
|
return response.data;
|
|
};
|
|
|
|
export const listAppraisals = async (params?: {
|
|
cycleId?: string;
|
|
status?: AppraisalStatus;
|
|
page?: number;
|
|
limit?: number;
|
|
}) => {
|
|
const response = await hrApi.get<Page<Appraisal>>("/appraisal", { params });
|
|
return response.data;
|
|
};
|
|
|
|
export const getAppraisal = async (id: string): Promise<Appraisal> => {
|
|
const response = await hrApi.get<Appraisal>(`/appraisal/${id}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const submitSelf = async (
|
|
id: string,
|
|
payload: {
|
|
ratings: { code: string; score: number; comment?: string }[];
|
|
comment?: string;
|
|
},
|
|
) => {
|
|
const response = await hrApi.post<Appraisal>(`/appraisal/${id}/self`, payload);
|
|
return response.data;
|
|
};
|
|
|
|
export const submitManager = async (
|
|
id: string,
|
|
payload: {
|
|
ratings: { code: string; score: number; comment?: string }[];
|
|
goals?: { id: string; achievementPercent?: number; comment?: string }[];
|
|
comment?: string;
|
|
},
|
|
) => {
|
|
const response = await hrApi.post<Appraisal>(`/appraisal/${id}/manager`, payload);
|
|
return response.data;
|
|
};
|
|
|
|
export const acknowledge = async (id: string, comment?: string) => {
|
|
const response = await hrApi.patch<Appraisal>(`/appraisal/${id}/acknowledge`, {
|
|
comment,
|
|
});
|
|
return response.data;
|
|
};
|
|
|
|
export const addGoal = async (
|
|
id: string,
|
|
payload: { title: string; description?: string; target?: string; weight?: string },
|
|
) => {
|
|
const response = await hrApi.post<AppraisalGoal>(`/appraisal/${id}/goals`, payload);
|
|
return response.data;
|
|
};
|