mirror of
https://github.com/strapi/strapi.git
synced 2025-12-14 00:29:32 +00:00
Merge pull request #21099 from strapi/v5/fix-issue-21079
fix: issue 21079 on v5
This commit is contained in:
commit
2842f97374
@ -46,7 +46,7 @@ export declare namespace FindAll {
|
|||||||
// TODO make the types for this
|
// TODO make the types for this
|
||||||
export interface Request {
|
export interface Request {
|
||||||
body: {};
|
body: {};
|
||||||
query: Modules.EntityService.Params.Pick<'admin::user', 'filters'> & {
|
query: Modules.EntityService.Params.Pick<'admin::user', 'filters' | '_q'> & {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import { useIntl } from 'react-intl';
|
|||||||
|
|
||||||
import { CREATOR_FIELDS } from '../../../constants/attributes';
|
import { CREATOR_FIELDS } from '../../../constants/attributes';
|
||||||
import { useContentTypeSchema } from '../../../hooks/useContentTypeSchema';
|
import { useContentTypeSchema } from '../../../hooks/useContentTypeSchema';
|
||||||
|
import { useDebounce } from '../../../hooks/useDebounce';
|
||||||
import { Schema } from '../../../hooks/useDocument';
|
import { Schema } from '../../../hooks/useDocument';
|
||||||
import { useGetContentTypeConfigurationQuery } from '../../../services/contentTypes';
|
import { useGetContentTypeConfigurationQuery } from '../../../services/contentTypes';
|
||||||
import { getMainField } from '../../../utils/attributes';
|
import { getMainField } from '../../../utils/attributes';
|
||||||
@ -224,20 +225,26 @@ const FiltersImpl = ({ disabled, schema }: FiltersProps) => {
|
|||||||
* -----------------------------------------------------------------------------------------------*/
|
* -----------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
const AdminUsersFilter = ({ name }: Filters.ValueInputProps) => {
|
const AdminUsersFilter = ({ name }: Filters.ValueInputProps) => {
|
||||||
const [page, setPage] = React.useState(1);
|
const [pageSize, setPageSize] = React.useState(10);
|
||||||
|
const [search, setSearch] = React.useState('');
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
|
||||||
|
const debouncedSearch = useDebounce(search, 300);
|
||||||
|
|
||||||
const { data, isLoading } = useAdminUsers({
|
const { data, isLoading } = useAdminUsers({
|
||||||
page,
|
pageSize,
|
||||||
|
_q: debouncedSearch,
|
||||||
});
|
});
|
||||||
const field = useField(name);
|
const field = useField(name);
|
||||||
|
|
||||||
const handleOpenChange = (isOpen?: boolean) => {
|
const handleOpenChange = (isOpen?: boolean) => {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
setPage(1);
|
setPageSize(10);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const users = data?.users || [];
|
const { users = [], pagination } = data ?? {};
|
||||||
|
const { pageCount = 1, page = 1 } = pagination ?? {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Combobox
|
<Combobox
|
||||||
@ -249,7 +256,11 @@ const AdminUsersFilter = ({ name }: Filters.ValueInputProps) => {
|
|||||||
onOpenChange={handleOpenChange}
|
onOpenChange={handleOpenChange}
|
||||||
onChange={(value) => field.onChange(name, value)}
|
onChange={(value) => field.onChange(name, value)}
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
onLoadMore={() => setPage((prev) => prev + 1)}
|
onLoadMore={() => setPageSize(pageSize + 10)}
|
||||||
|
hasMoreItems={page < pageCount}
|
||||||
|
onInputChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setSearch(e.currentTarget.value);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{users.map((user) => {
|
{users.map((user) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user