frontend fully integreated with the backend
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
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),
|
||||
}
|
||||
Reference in New Issue
Block a user