From 482c97033be04cb7706255a6cf82d9d7f16815d7 Mon Sep 17 00:00:00 2001 From: Jakz Date: Thu, 2 May 2024 11:36:42 +0800 Subject: [PATCH] Able to delete gallery --- .../Gallery/DeleteGalleryBottomSheet.tsx | 73 +++++++++++++++ .../ProfileView/GalleryPreviewCard.tsx | 71 ++------------ .../GalleryPreviewCardBottomSheet.tsx | 92 +++++++++++++++++++ .../DeleteGalleryConfirmation.tsx | 2 +- .../shared/src/hooks}/useDeleteGallery.ts | 2 +- 5 files changed, 174 insertions(+), 66 deletions(-) create mode 100644 apps/mobile/src/components/Gallery/DeleteGalleryBottomSheet.tsx create mode 100644 apps/mobile/src/components/ProfileView/GalleryPreviewCardBottomSheet.tsx rename {apps/web/src/components/MultiGallery => packages/shared/src/hooks}/useDeleteGallery.ts (93%) diff --git a/apps/mobile/src/components/Gallery/DeleteGalleryBottomSheet.tsx b/apps/mobile/src/components/Gallery/DeleteGalleryBottomSheet.tsx new file mode 100644 index 0000000000..3458435190 --- /dev/null +++ b/apps/mobile/src/components/Gallery/DeleteGalleryBottomSheet.tsx @@ -0,0 +1,73 @@ +import { useCallback } from 'react'; +import { View } from 'react-native'; +import { graphql, useFragment } from 'react-relay'; +import useDeleteGallery from 'shared/hooks/useDeleteGallery'; + +import { Button } from '~/components/Button'; +import { Typography } from '~/components/Typography'; +import { useBottomSheetModalActions } from '~/contexts/BottomSheetModalContext'; +import { DeleteGalleryBottomSheet$key } from '~/generated/DeleteGalleryBottomSheet.graphql'; +import { contexts } from '~/shared/analytics/constants'; + +type Props = { + galleryRef: DeleteGalleryBottomSheet$key; +}; + +export default function DeleteGalleryBottomSheet({ galleryRef }: Props) { + const gallery = useFragment( + graphql` + fragment DeleteGalleryBottomSheet on Gallery { + dbid + } + `, + galleryRef + ); + const deleteGallery = useDeleteGallery(); + const { hideBottomSheetModal } = useBottomSheetModalActions(); + + const handleBack = useCallback(() => { + hideBottomSheetModal(); + }, [hideBottomSheetModal]); + + const handleDelete = useCallback(() => { + deleteGallery(gallery.dbid); + hideBottomSheetModal(); + }, [deleteGallery, gallery, hideBottomSheetModal]); + + return ( + + + + Delete gallery + + + Are you sure you want to delete this gallery? + + + + +