48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import { api } from '@/lib/api'
|
|
import type {
|
|
PaginatedResponse,
|
|
DriverProfileResponse,
|
|
DriverComplianceConfigResponse,
|
|
} from '@/types/api'
|
|
|
|
import type { PageParams } from './master'
|
|
|
|
// ─── Driver Profiles ──────────────────────────────────────────────────────────
|
|
|
|
export interface DriverProfileBody {
|
|
userId: string
|
|
licenseNumber: string
|
|
licenseExpiry: string
|
|
medicalClearanceExpiry: string
|
|
isActive?: boolean
|
|
}
|
|
|
|
export const drivers = {
|
|
list: (params?: PageParams) =>
|
|
api.get<PaginatedResponse<DriverProfileResponse>>('/driver-profiles', { params }).then(r => r.data),
|
|
|
|
get: (id: string) =>
|
|
api.get<DriverProfileResponse>(`/driver-profiles/${id}`).then(r => r.data),
|
|
|
|
create: (body: DriverProfileBody) =>
|
|
api.post<DriverProfileResponse>('/driver-profiles', body).then(r => r.data),
|
|
|
|
update: (id: string, body: Partial<DriverProfileBody>) =>
|
|
api.put<DriverProfileResponse>(`/driver-profiles/${id}`, body).then(r => r.data),
|
|
}
|
|
|
|
// ─── Compliance Config ────────────────────────────────────────────────────────
|
|
|
|
export interface ComplianceConfigBody {
|
|
enforceLicenseExpiry: boolean
|
|
enforceMedicalClearance: boolean
|
|
}
|
|
|
|
export const compliance = {
|
|
get: () =>
|
|
api.get<DriverComplianceConfigResponse>('/driver-profiles/compliance').then(r => r.data),
|
|
|
|
update: (body: ComplianceConfigBody) =>
|
|
api.put<DriverComplianceConfigResponse>('/driver-profiles/compliance', body).then(r => r.data),
|
|
}
|