import React, { Fragment, useEffect, useState } from 'react'; import http from '@/api/http'; import { UUID } from '@/api/definitions'; import { Transformers, 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'; const UsersContainerV2 = () => { const [ users, setUsers ] = useState([]); const [ selected, setSelected ] = useState([]); useEffect(() => { document.title = 'Admin | Users'; }, []); useEffect(() => { http.get('/api/application/users') .then(({ data }) => { setUsers(data.data.map(Transformers.toUser)); }) .catch(console.error); }, []); const onRowChange = (user: User, checked: boolean) => { setSelected((state) => { return checked ? [ ...state, user.uuid ] : selected.filter((uuid) => uuid !== user.uuid); }); }; const selectAllChecked = users.length > 0 && selected.length > 0; const onSelectAll = () => setSelected((state) => state.length > 0 ? [] : users.map(({ uuid }) => uuid)); return (
0} duration={'duration-75'}>
{users.map(user => ( ))}
Email
); }; export default UsersContainerV2;