56 lines
1.2 KiB
TypeScript
56 lines
1.2 KiB
TypeScript
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 type FeedbackType =
|
|
| "TRUCK_DID_NOT_PASS"
|
|
| "RATING"
|
|
| "SUGGESTION"
|
|
| "OTHER";
|
|
|
|
export interface AdminFeedbackItem {
|
|
id: string;
|
|
userId: number;
|
|
routeId: string | null;
|
|
userName?: string;
|
|
colonia?: string;
|
|
type: FeedbackType;
|
|
message: string;
|
|
rating?: number;
|
|
createdAt: string;
|
|
}
|
|
|
|
export const listAllRoutes = () =>
|
|
apiFetch<AdminRouteItem[]>("/api/admin/routes");
|
|
|
|
export const listAllFeedback = () =>
|
|
apiFetch<AdminFeedbackItem[]>("/api/admin/feedback");
|
|
|
|
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({}),
|
|
},
|
|
);
|