Update UserFilter paginateFetch def

This commit is contained in:
CuriousCorrelation committed 2022-07-12 17:35:25 +05:30
1 parent 6a0d1de57a
commit ec51e495a1
1 file changed
+15 -1
+15 -1
View File
@@ -1,7 +1,9 @@
import { observer } from "mobx-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import User from "~/models/User";
import FilterOptions from "~/components/FilterOptions";
import { PaginatedItem } from "~/components/PaginatedList";
import useStores from "~/hooks/useStores";
type Props = {
@@ -36,6 +38,18 @@ function UserFilter(props: Props) {
];
}, [users.all, t]);
const paginateFetch = React.useCallback(
async (options: PaginatedItem) => {
const list = await users.fetchPage(options);
return list.map((user: User) => ({
key: user.id,
id: user.id,
label: user.name,
}));
},
[users]
);
return (
<FilterOptions
options={options}
@@ -44,7 +58,7 @@ function UserFilter(props: Props) {
defaultLabel={t("Any author")}
selectedPrefix={`${t("Author")}:`}
searchable
paginateFetch={users.fetchPage}
paginateFetch={paginateFetch}
/>
);
}