From eff243bc360fb10c3be21330e6497815ca31e6bd Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Wed, 31 Jan 2024 09:39:16 +0100 Subject: [PATCH] delete confirmation popup --- .../ItemPopupComponents/HeaderView.tsx | 22 ++++++++++++++++++- src/Components/Map/UtopiaMap.tsx | 2 +- src/Components/Profile/ProfileSettings.tsx | 2 +- src/Components/Templates/DialogModal.tsx | 6 +++-- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx index ebeb0cbb..c34caaeb 100644 --- a/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx @@ -9,6 +9,7 @@ import { useHasUserPermission } from "../../hooks/usePermissions"; import { useAuth } from "../../../Auth"; import { getValue } from "../../../../Utils/GetValue"; import { useAssetApi } from '../../../AppShell/hooks/useAssets' +import DialogModal from "../../../Templates/DialogModal"; @@ -18,6 +19,9 @@ export function HeaderView({ item, setItemFormPopup }: { setItemFormPopup?: React.Dispatch> }) { + + const [modalOpen, setModalOpen] = React.useState(false); + const [loading, setLoading] = React.useState(false); const removeItem = useRemoveItem(); @@ -49,7 +53,12 @@ export function HeaderView({ item, setItemFormPopup }: { } setLoading(false); map.closePopup(); + window.history.pushState({}, "", "/"); + event.stopPropagation(); + } + const openDeleteModal = async (event: React.MouseEvent) => { + setModalOpen(true); event.stopPropagation(); } @@ -62,6 +71,7 @@ export function HeaderView({ item, setItemFormPopup }: { return ( + <>
{ @@ -96,7 +106,7 @@ export function HeaderView({ item, setItemFormPopup }: { } {item.layer.api.deleteItem && hasUserPermission(item.layer.api?.collectionName!, "delete") &&
  • - + {loading ? : @@ -108,5 +118,15 @@ export function HeaderView({ item, setItemFormPopup }: {
  • }
    + (setModalOpen(false)) }> + Do you want to delte {item.name}? +
    +
    + + +
    +
    +
    + ) } diff --git a/src/Components/Map/UtopiaMap.tsx b/src/Components/Map/UtopiaMap.tsx index e4c93448..82d6b5fc 100644 --- a/src/Components/Map/UtopiaMap.tsx +++ b/src/Components/Map/UtopiaMap.tsx @@ -58,7 +58,7 @@ function UtopiaMap({ props.setItemFormPopup({ layer: props.selectNewItemPosition, position: e.latlng }) props.setSelectNewItemPosition(null) } - }, + } }) return null } diff --git a/src/Components/Profile/ProfileSettings.tsx b/src/Components/Profile/ProfileSettings.tsx index 0ee04033..7f299f7e 100644 --- a/src/Components/Profile/ProfileSettings.tsx +++ b/src/Components/Profile/ProfileSettings.tsx @@ -212,7 +212,7 @@ export function ProfileSettings() { setCrop(c)} aspect={1} > - + {showCloseButton && }