Files
admin-web/src/modules/appointment-calendar/cargoVerificationApi.ts
T

14 lines
1.7 KiB
TypeScript

import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
import type { PlanningSource } from './planningApi'
export interface CargoVerification { version: number; sourceVersion: string | null; destinationKey: string; sourcePackages: number | null; packageCount: number | null; shipmentReferences: string[]; remark: string | null; operatorName: string | null; verifiedAt: string }
export interface CargoVerificationContext { source: PlanningSource; verification: CargoVerification | null; allocatedPackages: number; unknownAllocationCount: number; effectivePackages: number | null; availablePackages: number | null; sourceChanged: boolean; allowedActions: string[]; blockReasons: string[] }
export interface CargoVerificationSource { sourceKey: string; customerId: string; destinationKey?: string }
export interface SaveCargoVerification { destinationKey: string; expectedSourceVersion: string | null; expectedVersion: number; packageCount: number | null; shipmentReferences: string[]; remark: string | null; idempotencyKey: string }
const path = (key: string) => `/platform/v1/last-leg/appointment-planning/sources/${encodeURIComponent(key)}/cargo-verification`
export async function getCargoVerification(source: CargoVerificationSource) {
return unwrapApiResponse(await http.get<ApiEnvelope<CargoVerificationContext>, ApiEnvelope<CargoVerificationContext>>(path(source.sourceKey), { params: { customerId: source.customerId, destinationKey: source.destinationKey } }))
}
export async function saveCargoVerification(source: CargoVerificationSource, body: SaveCargoVerification) {
return unwrapApiResponse(await http.post<ApiEnvelope<CargoVerification>, ApiEnvelope<CargoVerification>>(path(source.sourceKey), body, { params: { customerId: source.customerId } }))
}