import React, { Fragment, useEffect, useState } from 'react'; import { UUID } from '@/api/definitions'; import { User } from '@definitions/admin'; import { Transition } from '@/components/elements/transitions'; import { LockOpenIcon, PlusIcon, SupportIcon, TrashIcon } from '@heroicons/react/solid'; import { Button } from '@/components/elements/button/index'; import { Checkbox, InputField } from '@/components/elements/inputs'; import UserTableRow from '@/components/admin/users/UserTableRow'; import { useGetUsers } from '@/api/admin/users'; import TFootPaginated from '@/components/elements/table/TFootPaginated'; import extractSearchFilters from '@/helpers/extractSearchFilters'; import useDebouncedState from '@/plugins/useDebouncedState'; const filters = [ 'id', 'uuid', 'external_id', 'username', 'email' ] as const; const UsersContainer = () => { const [ search, setSearch ] = useDebouncedState('', 500); const [ selected, setSelected ] = useState([]); const { data: users } = useGetUsers(extractSearchFilters(search, filters)); useEffect(() => { document.title = 'Admin | Users'; }, []); const onRowChange = (user: User, checked: boolean) => { setSelected((state) => { return checked ? [ ...state, user.uuid ] : selected.filter((uuid) => uuid !== user.uuid); }); }; const selectAllChecked = users && users.items.length > 0 && selected.length > 0; const onSelectAll = () => setSelected((state) => state.length > 0 ? [] : users?.items.map(({ uuid }) => uuid) || []); return (
setSearch(e.currentTarget.value)} />
0} duration={'duration-75'}>
{users?.items.map(user => ( ))} {users && }
Email
); }; export default UsersContainer;