A social knowledge tool for researchers built on ATProto
1import { Button, Stack, Modal } from '@mantine/core';
2import useRemoveCardFromLibrary from '../../lib/mutations/useRemoveCardFromLibrary';
3import { notifications } from '@mantine/notifications';
4import { DANGER_OVERLAY_PROPS } from '@/styles/overlays';
5
6interface Props {
7 isOpen: boolean;
8 onClose: () => void;
9 cardId: string;
10}
11
12export default function RemoveCardFromLibraryModal(props: Props) {
13 const removeCardFromLibrary = useRemoveCardFromLibrary();
14
15 const handleRemoveCardFromLibrary = () => {
16 removeCardFromLibrary.mutate(props.cardId, {
17 onError: () => {
18 notifications.show({
19 message: 'Could not remove card from library.',
20 position: 'top-center',
21 });
22 },
23 onSettled: () => {
24 props.onClose();
25 },
26 });
27 };
28
29 return (
30 <Modal
31 opened={props.isOpen}
32 onClose={props.onClose}
33 withCloseButton={false}
34 title="Remove card from library"
35 size={'xs'}
36 overlayProps={DANGER_OVERLAY_PROPS}
37 centered
38 >
39 <Stack>
40 <Button variant="subtle" size="md" color="gray" onClick={props.onClose}>
41 Cancel
42 </Button>
43 <Button
44 color="red"
45 size="md"
46 onClick={handleRemoveCardFromLibrary}
47 loading={removeCardFromLibrary.isPending}
48 >
49 Remove
50 </Button>
51 </Stack>
52 </Modal>
53 );
54}