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,31 @@
import { entity as entityApi } from '../api';
import { createListAutomat } from './createListAutomat';
/**
* @typedef {Object} Entity
* @property {string|number} id Entity id.
* @property {string|number} customergroupId Owning customer group id.
* @property {string|null} firstName First name.
* @property {string} name Last / company name.
*/
/**
* Company customers and contacts (`GET /api/entity`).
*
* @type {import('react-automat').Automat<import('./createListAutomat').ListAutomatState>}
*/
export const entityAutomat = createListAutomat({
name: 'entity',
fetch: async () => {
const data = await entityApi.list();
return data.entities ?? [];
},
sort: (items) =>
[...items].sort((a, b) => {
const byName = String(a.name).localeCompare(String(b.name), 'de');
if (byName !== 0) return byName;
return String(a.firstName ?? '').localeCompare(String(b.firstName ?? ''), 'de');
}),
});
export default entityAutomat;