bigbuffet-rw/packages/pl-hooks/lib/normalizers/status-list.ts
marcin mikołajczak ad24c03084 pl-hooks: Add new queries
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-10-28 14:58:32 +01:00

15 lines
513 B
TypeScript

import { PaginatedResponse, Status } from 'pl-api';
import { importEntities } from 'pl-hooks/importer';
const minifyStatusList = ({ previous, next, items, ...response }: PaginatedResponse<Status>): PaginatedResponse<string> => {
importEntities({ statuses: items });
return {
...response,
previous: previous ? () => previous().then(minifyStatusList) : null,
next: next ? () => next().then(minifyStatusList) : null,
items: items.map(status => status.id),
};
};
export { minifyStatusList };