u
This commit is contained in:
21
src/automats/accountAutomat.js
Normal file
21
src/automats/accountAutomat.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @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;
|
||||
Reference in New Issue
Block a user