This commit is contained in:
seb
2026-10-04 21:04:40 +02:00
parent 669954b496
commit f765b87336
59 changed files with 1491 additions and 2045 deletions

View File

@@ -0,0 +1,32 @@
import { delivery as deliveryApi } from '../api';
import { createListAutomat } from './createListAutomat';
/**
* @typedef {Object} DeliverySummary
* @property {string|number} id Delivery id.
* @property {string} number Server-allocated manifest number.
* @property {string|null} externalNumber User-entered reference.
* @property {string} type Always `'delivery'`.
* @property {string|number|null} supplierId Supplier id.
* @property {string} date Delivery date (ISO).
*/
/**
* Company goods receipts (`GET /api/delivery`).
*
* Backs the delivery list page and the quote/order manifest lists share the
* same pattern through their own automats.
*
* @type {import('react-automat').Automat<import('./createListAutomat').ListAutomatState>}
*/
export const deliveryAutomat = createListAutomat({
name: 'delivery',
fetch: async () => {
const data = await deliveryApi.list();
return data.deliveries ?? [];
},
sort: (items) =>
[...items].sort((a, b) => String(b.date).localeCompare(String(a.date))),
});
export default deliveryAutomat;