2022-12-16 02:06:14 +00:00
|
|
|
import { BanIcon, DotsVerticalIcon, LockOpenIcon, PencilIcon, SupportIcon, TrashIcon } from '@heroicons/react/solid';
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
|
|
|
import Checkbox from '@/components/elements/inputs/Checkbox';
|
|
|
|
import { Dropdown } from '@/components/elements/dropdown';
|
|
|
|
import { Dialog } from '@/components/elements/dialog';
|
2023-01-25 18:14:39 +00:00
|
|
|
import type { User } from '@definitions/admin';
|
2022-12-16 02:06:14 +00:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
user: User;
|
|
|
|
selected?: boolean;
|
|
|
|
onRowChange: (user: User, selected: boolean) => void;
|
|
|
|
}
|
|
|
|
|
2023-01-25 18:14:39 +00:00
|
|
|
function UserTableRow({ user, selected, onRowChange }: Props) {
|
2022-12-16 02:06:14 +00:00
|
|
|
const [visible, setVisible] = useState(false);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2022-12-21 21:27:50 +00:00
|
|
|
<Dialog.Confirm
|
|
|
|
title={'Delete account'}
|
|
|
|
open={visible}
|
|
|
|
onClose={() => setVisible(false)}
|
|
|
|
onConfirmed={() => {
|
|
|
|
console.log('yeet');
|
|
|
|
}}
|
|
|
|
>
|
2022-12-16 02:06:14 +00:00
|
|
|
This account will be permanently deleted.
|
2022-12-21 21:27:50 +00:00
|
|
|
</Dialog.Confirm>
|
|
|
|
|
2022-12-16 02:06:14 +00:00
|
|
|
<tr>
|
|
|
|
<td className={'whitespace-nowrap'}>
|
2023-01-12 19:31:47 +00:00
|
|
|
<div className={'flex w-8 items-center justify-end'}>
|
2022-12-16 02:06:14 +00:00
|
|
|
<Checkbox checked={selected} onChange={e => onRowChange(user, e.currentTarget.checked)} />
|
|
|
|
</div>
|
|
|
|
</td>
|
2023-01-12 19:31:47 +00:00
|
|
|
<td className={'whitespace-nowrap py-4 pl-6'}>
|
2022-12-16 02:06:14 +00:00
|
|
|
<div className={'flex items-center'}>
|
2023-01-12 19:31:47 +00:00
|
|
|
<div className={'h-10 w-10'}>
|
|
|
|
<img src={user.avatarUrl} className={'h-10 w-10 rounded-full'} alt={'User avatar'} />
|
2022-12-16 02:06:14 +00:00
|
|
|
</div>
|
|
|
|
<div className={'ml-4'}>
|
|
|
|
<p className={'font-medium'}>{user.email}</p>
|
|
|
|
<p className={'text-sm text-neutral-400'}>{user.uuid}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</td>
|
2023-01-12 19:31:47 +00:00
|
|
|
<td className={'whitespace-nowrap py-4 pl-2'}>
|
2022-12-16 02:06:14 +00:00
|
|
|
{user.isUsingTwoFactor && (
|
|
|
|
<span
|
|
|
|
className={
|
2023-01-12 19:31:47 +00:00
|
|
|
'rounded bg-green-100 px-2 py-0.5 text-xs font-semibold uppercase text-green-700'
|
2022-12-16 02:06:14 +00:00
|
|
|
}
|
|
|
|
>
|
|
|
|
2-FA Enabled
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
</td>
|
2023-01-25 18:14:39 +00:00
|
|
|
<td className="whitespace-nowrap px-6 py-4">
|
2022-12-16 02:06:14 +00:00
|
|
|
<Dropdown>
|
2023-01-25 18:14:39 +00:00
|
|
|
<Dropdown.Button className="px-2">
|
2022-12-16 02:06:14 +00:00
|
|
|
<DotsVerticalIcon />
|
|
|
|
</Dropdown.Button>
|
2023-01-25 18:14:39 +00:00
|
|
|
<Dropdown.Item to={`/admin/users/${user.id}`} icon={<PencilIcon />}>
|
|
|
|
Edit
|
|
|
|
</Dropdown.Item>
|
2022-12-16 02:06:14 +00:00
|
|
|
<Dropdown.Item icon={<SupportIcon />}>Reset Password</Dropdown.Item>
|
|
|
|
<Dropdown.Item icon={<LockOpenIcon />} disabled={!user.isUsingTwoFactor}>
|
|
|
|
Disable 2-FA
|
|
|
|
</Dropdown.Item>
|
|
|
|
<Dropdown.Item icon={<BanIcon />}>Suspend</Dropdown.Item>
|
|
|
|
<Dropdown.Gap />
|
|
|
|
<Dropdown.Item icon={<TrashIcon />} onClick={() => setVisible(true)} danger>
|
|
|
|
Delete Account
|
|
|
|
</Dropdown.Item>
|
|
|
|
</Dropdown>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</>
|
|
|
|
);
|
2023-01-25 18:14:39 +00:00
|
|
|
}
|
2022-12-16 02:06:14 +00:00
|
|
|
|
|
|
|
export default UserTableRow;
|