22 lines
597 B
JavaScript
22 lines
597 B
JavaScript
/**
|
|
* @file accountAutomat.js
|
|
* @description Manages cached payment accounts (`GET /api/account`) for the selected company.
|
|
*/
|
|
|
|
import { createListAutomat } from './createListAutomat';
|
|
import { account as accountApi } from '../api';
|
|
|
|
export const accountAutomat = createListAutomat({
|
|
name: 'account',
|
|
fetch: async () => {
|
|
const res = await accountApi.list();
|
|
return Array.isArray(res?.accounts) ? res.accounts : [];
|
|
},
|
|
sort: (items) =>
|
|
[...items].sort((a, b) =>
|
|
String(a.name ?? '').localeCompare(String(b.name ?? ''), 'de')
|
|
),
|
|
});
|
|
|
|
export default accountAutomat;
|