48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { apiClient } from "./client";
|
|
import { API_ENDPOINTS } from "../config/api";
|
|
|
|
export interface Attendance {
|
|
id: string;
|
|
checkInTime: string;
|
|
checkOutTime?: string;
|
|
type: string;
|
|
notes?: string;
|
|
}
|
|
|
|
export const attendanceApi = {
|
|
getHistory: async (token: string): Promise<Attendance[]> => {
|
|
try {
|
|
const response = await apiClient.get(API_ENDPOINTS.ATTENDANCE.HISTORY, {
|
|
headers: { Authorization: `Bearer ${token}` },
|
|
});
|
|
return response.data;
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
},
|
|
|
|
checkIn: async (type: string, token: string): Promise<void> => {
|
|
try {
|
|
await apiClient.post(
|
|
API_ENDPOINTS.ATTENDANCE.CHECK_IN,
|
|
{ type },
|
|
{ headers: { Authorization: `Bearer ${token}` } },
|
|
);
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
},
|
|
|
|
checkOut: async (token: string): Promise<void> => {
|
|
try {
|
|
await apiClient.post(
|
|
API_ENDPOINTS.ATTENDANCE.CHECK_OUT,
|
|
{},
|
|
{ headers: { Authorization: `Bearer ${token}` } },
|
|
);
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
},
|
|
};
|