feat: Improve the administrator profile

This commit is contained in:
Diego Mireles
2026-05-23 08:58:23 -06:00
parent 5b8711cdf0
commit 5833063053
8 changed files with 493 additions and 52 deletions

View File

@@ -0,0 +1,34 @@
import { apiFetch } from "../lib/api";
export interface AdminRouteItem {
routeId: string;
name: string;
truckId: number;
status: string;
currentPositionId: number;
arrivalResult: "PENDING" | "ARRIVED" | "FAILED" | "CANCELLED";
cancelled: boolean;
cancelReason?: string;
updatedAt?: string;
}
export const listAllRoutes = () =>
apiFetch<AdminRouteItem[]>("/api/admin/routes");
export const cancelRoute = (routeId: string, reason?: string) =>
apiFetch<{ message: string; routeId: string }>(
`/api/admin/routes/${routeId}/cancel`,
{
method: "POST",
body: JSON.stringify(reason ? { reason } : {}),
},
);
export const resumeRoute = (routeId: string) =>
apiFetch<{ message: string; routeId: string }>(
`/api/admin/routes/${routeId}/resume`,
{
method: "POST",
body: JSON.stringify({}),
},
);