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,28 @@
import { order as orderApi } from '../api';
import { createListAutomat } from './createListAutomat';
/**
* @typedef {Object} OrderSummary
* @property {string|number} id Order id.
* @property {string} number Order number.
* @property {string} type Always `'order'`.
* @property {string|number|null} entityId Customer id.
* @property {string} date Delivery date (ISO).
*/
/**
* Company sales orders (`GET /api/order`).
*
* @type {import('react-automat').Automat<import('./createListAutomat').ListAutomatState>}
*/
export const orderAutomat = createListAutomat({
name: 'order',
fetch: async () => {
const data = await orderApi.list();
return data.orders ?? [];
},
sort: (items) =>
[...items].sort((a, b) => String(b.date).localeCompare(String(a.date))),
});
export default orderAutomat;