u
This commit is contained in:
32
src/automats/deliveryAutomat.js
Normal file
32
src/automats/deliveryAutomat.js
Normal 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;
|
||||
Reference in New Issue
Block a user