import { LockOpenIcon, PlusIcon, SupportIcon, TrashIcon } from '@heroicons/react/solid'; import { Fragment, useEffect, useState } from 'react'; import { NavLink } from 'react-router-dom'; import { useGetUsers } from '@/api/admin/users'; import type { UUID } from '@/api/definitions'; import { Transition } from '@/components/elements/transitions'; import { Button } from '@/components/elements/button/index'; import Checkbox from '@/components/elements/inputs/Checkbox'; import InputField from '@/components/elements/inputs/InputField'; import UserTableRow from '@/components/admin/users/UserTableRow'; import TFootPaginated from '@/components/elements/table/TFootPaginated'; import type { User } from '@definitions/admin'; import extractSearchFilters from '@/helpers/extractSearchFilters'; import useDebouncedState from '@/plugins/useDebouncedState'; import { Shape } from '@/components/elements/button/types'; const filters = ['id', 'uuid', 'external_id', 'username', 'email'] as const; function UsersContainer() { const [search, setSearch] = useDebouncedState('', 500); const [selected, setSelected] = useState([]); const { data: users } = useGetUsers( extractSearchFilters(search, filters, { splitUnmatched: true, returnUnmatched: true, }), ); 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 ? : null}
Email
); } export default UsersContainer;