Skip to content

Commit

Permalink
Add confirmation modal before delete user
Browse files Browse the repository at this point in the history
 (#147)
  • Loading branch information
kimurash committed Nov 21, 2024
1 parent 71df172 commit ebf1684
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions frontend/app/components/users/UserDeleteButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { Button } from '@mantine/core';
import { Button, Center, Modal, rem } from '@mantine/core';
import { useDisclosure } from '@mantine/hooks';
import { MdDeleteForever } from 'react-icons/md';
import { RiArrowGoBackLine } from 'react-icons/ri';

interface UserDeleteButtonProps {
id: number;
Expand All @@ -9,15 +12,38 @@ const UserDeleteButton = ({
id,
handleDeleteUserButtonClick,
}: UserDeleteButtonProps) => {
const [opened, { open, close }] = useDisclosure();

return (
<Button
color="red"
variant="light"
bd="solid 2px"
onClick={() => handleDeleteUserButtonClick(id)}
>
削除
</Button>
<>
<Modal
opened={opened}
onClose={close}
title="本当に削除しますか?"
centered
>
<Center>
<Button
leftSection={<RiArrowGoBackLine />}
color="gray"
mr={rem(10)}
onClick={close}
>
キャンセル
</Button>
<Button
leftSection={<MdDeleteForever />}
color="red"
onClick={() => handleDeleteUserButtonClick(id)}
>
削除
</Button>
</Center>
</Modal>
<Button color="red" variant="light" bd="solid 2px" onClick={() => open()}>
削除
</Button>
</>
);
};

Expand Down

0 comments on commit ebf1684

Please sign in to comment.