This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user