import http from './http' import type { DeliveryTask } from '@/types/delivery' const MOCK = import.meta.env.VITE_USE_MOCK === 'true' const BASE = '/sl/projection/deliveries' export async function listDeliveries(opts?: { includeFinished?: boolean includeAborted?: boolean }): Promise { if (MOCK) { const { mockDeliveries } = await import('@/mock/data/deliveries') return mockDeliveries() } const params: Record = {} if (opts?.includeFinished === false) params.includeFinished = 'false' if (opts?.includeAborted === false) params.includeAborted = 'false' const { data } = await http.get(BASE, { params }) return Array.isArray(data) ? data : [] } export async function cancelDelivery(id: number): Promise { if (MOCK) return await http.post(`${BASE}/${id}/cancel`) } export async function resendDelivery(id: number): Promise { if (MOCK) return await http.post(`${BASE}/${id}/resend`) } export async function forceCompleteDelivery(id: number): Promise { if (MOCK) return await http.post(`${BASE}/${id}/force-complete`) }