A social knowledge tool for researchers built on ATProto
at development 1.5 kB view raw
1import { Button, Stack, Modal } from '@mantine/core'; 2import useDeleteCollection from '../../lib/mutations/useDeleteCollection'; 3import { notifications } from '@mantine/notifications'; 4import { useRouter } from 'next/navigation'; 5import { DANGER_OVERLAY_PROPS } from '@/styles/overlays'; 6 7interface Props { 8 isOpen: boolean; 9 onClose: () => void; 10 collectionId: string; 11} 12 13export default function DeleteCollectionModal(props: Props) { 14 const deleteCollection = useDeleteCollection(); 15 const router = useRouter(); 16 17 const handleDeleteCollection = () => { 18 deleteCollection.mutate(props.collectionId, { 19 onSuccess: (fes) => { 20 props.onClose(); 21 router.push('./'); 22 }, 23 onError: () => { 24 notifications.show({ 25 message: 'Could not delete collection.', 26 position: 'top-center', 27 }); 28 }, 29 onSettled: () => { 30 props.onClose(); 31 }, 32 }); 33 }; 34 35 return ( 36 <Modal 37 opened={props.isOpen} 38 onClose={props.onClose} 39 withCloseButton={false} 40 title="Delete Collection" 41 size={'xs'} 42 overlayProps={DANGER_OVERLAY_PROPS} 43 centered 44 > 45 <Stack> 46 <Button variant="subtle" size="md" color="gray" onClick={props.onClose}> 47 Cancel 48 </Button> 49 <Button 50 color="red" 51 size="md" 52 onClick={handleDeleteCollection} 53 loading={deleteCollection.isPending} 54 > 55 Delete 56 </Button> 57 </Stack> 58 </Modal> 59 ); 60}