2023-01-10 08:59:26 +01:00
|
|
|
import UserDeleteForm from 'components/pages/settings/users/UserDeleteForm';
|
2022-12-27 01:57:59 +01:00
|
|
|
import { useRouter } from 'next/router';
|
|
|
|
import { useState } from 'react';
|
|
|
|
import { Button, Form, FormRow, Modal } from 'react-basics';
|
|
|
|
|
|
|
|
export default function UserDelete({ userId, onSave }) {
|
|
|
|
const [modal, setModal] = useState(null);
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
const handleDelete = async () => {
|
|
|
|
onSave();
|
|
|
|
await router.push('/users');
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleClose = () => setModal(null);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Form>
|
|
|
|
<FormRow label="Delete user">
|
|
|
|
<p>All user data will be deleted.</p>
|
|
|
|
<Button onClick={() => setModal('delete')}>Delete</Button>
|
|
|
|
</FormRow>
|
|
|
|
{modal === 'delete' && (
|
|
|
|
<Modal title="Delete user" onClose={handleClose}>
|
|
|
|
{close => <UserDeleteForm userId={userId} onSave={handleDelete} onClose={close} />}
|
|
|
|
</Modal>
|
|
|
|
)}
|
|
|
|
</Form>
|
|
|
|
);
|
|
|
|
}
|