headplane/app/routes/users/dialogs/remove.tsx

59 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-12-31 10:30:14 +05:30
import { XIcon } from '@primer/octicons-react';
import { Form, useSubmit } from 'react-router';
import { useState } from 'react';
2024-05-15 21:52:19 -04:00
2024-12-31 10:30:14 +05:30
import Button from '~/components/Button';
import Code from '~/components/Code';
import Dialog from '~/components/Dialog';
2024-05-15 21:52:19 -04:00
interface Props {
2024-12-31 10:30:14 +05:30
username: string;
2024-05-15 21:52:19 -04:00
}
export default function Remove({ username }: Props) {
2024-12-31 10:30:14 +05:30
const submit = useSubmit();
const dialogState = useState(false);
2024-05-15 21:52:19 -04:00
return (
<>
<Button
variant="light"
control={dialogState}
className="rounded-full p-0 w-8 h-8 flex items-center justify-center"
2024-05-15 21:52:19 -04:00
>
<XIcon className="w-4 h-4" />
</Button>
<Dialog control={dialogState}>
<Dialog.Panel control={dialogState}>
2024-12-31 10:30:14 +05:30
{(close) => (
2024-05-15 21:52:19 -04:00
<>
2024-12-31 10:30:14 +05:30
<Dialog.Title>Delete {username}?</Dialog.Title>
2024-05-15 21:52:19 -04:00
<Dialog.Text className="mb-8">
2024-12-31 10:30:14 +05:30
Are you sure you want to delete {username}? A deleted user
cannot be recovered.
2024-05-15 21:52:19 -04:00
</Dialog.Text>
<Form
method="POST"
onSubmit={(event) => {
2024-12-31 10:30:14 +05:30
submit(event.currentTarget);
2024-05-15 21:52:19 -04:00
}}
>
<input type="hidden" name="_method" value="delete" />
<input type="hidden" name="username" value={username} />
<div className="mt-6 flex justify-end gap-2 mt-6">
2024-12-31 10:30:14 +05:30
<Dialog.Action variant="cancel" onPress={close}>
2024-05-15 21:52:19 -04:00
Cancel
</Dialog.Action>
2024-12-31 10:30:14 +05:30
<Dialog.Action variant="confirm" onPress={close}>
2024-05-15 21:52:19 -04:00
Delete
</Dialog.Action>
</div>
</Form>
</>
)}
</Dialog.Panel>
</Dialog>
</>
2024-12-31 10:30:14 +05:30
);
2024-05-15 21:52:19 -04:00
}