import { useApi } from '~/composables/useApi' import type {ReceptionData, ReceptionPayload, WeightEntryData} from '~/services/dto/reception-data' import type {Ref} from "vue"; import type {ShipmentData, ShipmentPayload} from "~/services/dto/shipment-data"; import type {WeighingMode} from "~/composables/useWeighing"; export type WeightPayload = { reception?: string shipment?: string type: 'gross' | 'tare' dsd: number | null weight: number | null weighedAt: string | null } export async function createWeight(payload: WeightPayload) { const api = useApi() return api.post('weights', payload) } export async function updateWeight(id: number, payload: Partial) { const api = useApi() return api.patch(`weights/${id}`, payload,{ toastErrorKey: 'errors.weight.update', toastSuccessKey: 'success.weight.update' }) } export type UseWeighingShipmentOptions = { modeShipment: WeighingMode shipment: Ref updateShipment: (id: number, payload: ShipmentPayload) => Promise loadShipment?: (id: number) => Promise } export type UseWeighingOptions = { mode: WeighingMode reception: Ref updateReception: (id: number, payload: ReceptionPayload) => Promise loadReception?: (id: number) => Promise }