add phep
All checks were successful
Deploy on Master Change / deploy (push) Successful in 1m12s

This commit is contained in:
2026-07-06 10:58:38 +07:00
parent 573ff17581
commit f5dce38e11
6 changed files with 398 additions and 1 deletions

View File

@@ -813,6 +813,55 @@ export const apiPushAttendanceQLDT = async (rkId: number, date: string, period:
return res.json();
};
export interface LeaveRequestItem {
id: number;
date: string;
note: string;
reasonImage?: string;
rejectReason?: string | null;
period: number;
status: string; // 'Đang chờ', 'Phê duyệt', 'Từ chối'
approverId?: number | null;
createdAt: string;
student: {
id: number;
studentCode: string;
fullName: string;
phone?: string;
email: string;
avatar?: string;
};
}
export const apiFetchLeaveRequests = async (
classId: number,
courseId: number,
date: string
): Promise<LeaveRequestItem[]> => {
const res = await staffFetch(`/classes/${classId}/leave-requests?courseId=${courseId}&date=${date}`);
if (!res.ok) {
const err = await res.json().catch(() => ({}));
throw new Error(err.error || 'Failed to fetch leave requests');
}
return res.json();
};
export const apiUpdateLeaveStatus = async (
classId: number,
leaveId: number,
payload: { status: string; studentRkId: number; date: string; period: number }
): Promise<{ ok: boolean; message: string }> => {
const res = await staffFetch(`/classes/${classId}/leave-requests/${leaveId}/status`, {
method: 'POST',
body: JSON.stringify(payload),
});
if (!res.ok) {
const err = await res.json().catch(() => ({}));
throw new Error(err.error || 'Failed to update leave status');
}
return res.json();
};
async function staffUpload(path: string, form: FormData): Promise<Response> {
const headers = new Headers();
const token = getToken();