({
isOpen,
setOpen,
graphUID,
})
| 13 | } |
| 14 | |
| 15 | const DeleteGraphDialog: FC<DeleteGraphDialogProps> = ({ |
| 16 | isOpen, |
| 17 | setOpen, |
| 18 | graphUID, |
| 19 | }) => { |
| 20 | const { user } = useAuthState(); |
| 21 | const closeDialog = () => { |
| 22 | setOpen(false); |
| 23 | }; |
| 24 | |
| 25 | const deleteGraph = useCallback(async () => { |
| 26 | if (!user) { |
| 27 | throw new Error("No user found for deleting graph"); |
| 28 | } |
| 29 | |
| 30 | removePersonalGraph(user.uid, graphUID).then(() => { |
| 31 | setOpen(false); |
| 32 | }); |
| 33 | }, [graphUID]); |
| 34 | |
| 35 | return ( |
| 36 | <Modal isOpen={isOpen} closeModal={closeDialog} size="md"> |
| 37 | <div className="flex items-center justify-between border-b border-gray-200 pb-3"> |
| 38 | <h3 className="flex flex-row items-center gap-x-1.5 text-lg font-semibold leading-6 text-gray-900"> |
| 39 | Delete graph |
| 40 | </h3> |
| 41 | |
| 42 | <XMarkIcon |
| 43 | className="h-11 w-11 cursor-pointer rounded-full p-1.5 text-gray-400 transition-all duration-300 hover:bg-gray-100" |
| 44 | aria-hidden="true" |
| 45 | onClick={closeDialog} |
| 46 | /> |
| 47 | </div> |
| 48 | <span className="mt-3 flex flex-row gap-x-2"> |
| 49 | <button |
| 50 | type="button" |
| 51 | onClick={deleteGraph} |
| 52 | className="flex w-full flex-row items-center justify-center gap-x-1.5 rounded-md bg-red-500 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-red-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2" |
| 53 | > |
| 54 | <TrashIcon className="h-5 w-5 text-white" aria-hidden="true" /> |
| 55 | Delete graph |
| 56 | </button> |
| 57 | </span> |
| 58 | </Modal> |
| 59 | ); |
| 60 | }; |
| 61 | |
| 62 | export default DeleteGraphDialog; |
nothing calls this directly
no test coverage detected