misc_pterodactyl-panel/resources/scripts/components/admin/users/UsersContainerV2.tsx

76 lines
3 KiB
TypeScript
Raw Normal View History

import React, { useEffect, useState } from 'react';
import http from '@/api/http';
import { User } from '@definitions/admin/models';
import Transformers from '@definitions/admin/transformers';
2022-02-27 16:04:57 +00:00
import { LockOpenIcon, PlusIcon, SupportIcon, TrashIcon } from '@heroicons/react/solid';
import { Button } from '@/components/elements/button/index';
2022-02-27 02:51:40 +00:00
import { Checkbox, InputField } from '@/components/elements/inputs';
2022-02-27 16:04:57 +00:00
import UserTableRow from '@/components/admin/users/UserTableRow';
const UsersContainerV2 = () => {
const [ users, setUsers ] = useState<User[]>([]);
useEffect(() => {
document.title = 'Admin | Users';
}, []);
useEffect(() => {
http.get('/api/application/users')
.then(({ data }) => {
setUsers(data.data.map(Transformers.toUser));
})
.catch(console.error);
}, []);
return (
<div>
<div className={'flex justify-end mb-4'}>
<Button className={'shadow focus:ring-offset-2 focus:ring-offset-neutral-800'}>
Add User <PlusIcon className={'ml-2 w-5 h-5'}/>
</Button>
</div>
<div className={'relative flex items-center rounded-t bg-neutral-700 px-4 py-2'}>
2022-02-27 02:51:40 +00:00
<div className={'mr-6'}>
2022-02-27 16:04:57 +00:00
<Checkbox/>
2022-02-27 02:51:40 +00:00
</div>
<div className={'flex-1'}>
2022-02-27 16:04:57 +00:00
<InputField
type={'text'}
name={'filter'}
placeholder={'Begin typing to filter...'}
className={'w-56 focus:w-96'}
/>
2022-02-27 02:51:40 +00:00
</div>
<div className={'absolute rounded-t bg-neutral-700 w-full h-full top-0 left-0 flex items-center justify-end space-x-4 px-4'}>
<div className={'flex-1'}>
2022-02-27 16:04:57 +00:00
<Checkbox indeterminate/>
</div>
<Button.Text square>
2022-02-27 16:04:57 +00:00
<SupportIcon className={'w-4 h-4'}/>
</Button.Text>
<Button.Text square>
2022-02-27 16:04:57 +00:00
<LockOpenIcon className={'w-4 h-4'}/>
</Button.Text>
<Button.Text square>
2022-02-27 16:04:57 +00:00
<TrashIcon className={'w-4 h-4'}/>
</Button.Text>
</div>
2022-02-27 02:51:40 +00:00
</div>
<table className={'min-w-full rounded bg-neutral-700'}>
<thead className={'bg-neutral-900'}>
<tr>
<th scope={'col'} className={'w-8'}/>
<th scope={'col'} className={'text-left px-6 py-2 w-full'}>Email</th>
<th scope={'col'}/>
2022-02-27 02:26:53 +00:00
<th scope={'col'}/>
</tr>
</thead>
<tbody>
2022-02-27 16:04:57 +00:00
{users.map(user => <UserTableRow user={user} key={user.uuid}/>)}
</tbody>
</table>
</div>
);
};
export default UsersContainerV2;