import {useApi} from '~/composables/useApi' import type {ShipmentData, ShipmentPayload} from '~/services/dto/shipment-data' import type {WeightData} from '~/services/dto/weight-data' export async function getShipmentList(isValid: boolean|null = null) { const api = useApi() const query = isValid !== null ? { isValid: isValid} : {} return api.get('shipments', query, { toastErrorKey: 'errors.shipment.list' }) } export async function getShipment(id: number) { const api = useApi() return api.get(`shipments/${id}`, {}, { toastErrorKey: 'errors.shipment.fetch' }) } export async function createShipment(payload: ShipmentPayload = {}) { const api = useApi() return api.post('shipments', payload, { toastErrorKey: 'errors.shipment.create' }) } export async function updateShipment(id: number, payload: ShipmentPayload) { const api = useApi() return api.patch(`shipments/${id}`, payload, { toastErrorKey: 'errors.shipment.update', toastSuccessKey: 'success.shipment.update' }) } export async function getWeightShipment(): Promise { const api = useApi() return api.get('shipments/weigh', {}, { toastErrorKey: 'errors.shipment.weigh' }) }