From b6264ecf4f748317440336df5fe256172ea3cc4a Mon Sep 17 00:00:00 2001 From: Nick Taylor Date: Tue, 24 Oct 2023 22:49:10 -0400 Subject: [PATCH] chore: added delete account confirm dialog --- .../UserSettingsPage/user-settings-page.tsx | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/components/organisms/UserSettingsPage/user-settings-page.tsx b/components/organisms/UserSettingsPage/user-settings-page.tsx index 7db22dba81..4c716eacf6 100644 --- a/components/organisms/UserSettingsPage/user-settings-page.tsx +++ b/components/organisms/UserSettingsPage/user-settings-page.tsx @@ -22,6 +22,7 @@ import { useFetchUser } from "lib/hooks/useFetchUser"; import { getInterestOptions } from "lib/utils/getInterestOptions"; import { useToast } from "lib/hooks/useToast"; import { validateTwitterUsername } from "lib/utils/validate-twitter-username"; +import { Dialog, DialogContent, DialogHeader, DialogTitle } from "components/molecules/Dialog/dialog"; import CouponForm from "./coupon-form"; interface userSettingsPageProps { @@ -33,7 +34,50 @@ type EmailPreferenceType = { receive_collaboration?: boolean; }; +interface DeleteAccountModalProps { + open: boolean; + setOpen: (open: boolean) => void; + onDelete: () => void; +} + +const DeleteAccountModal = ({ open, setOpen, onDelete }: DeleteAccountModalProps) => { + return ( + + + + Connect Delete Account + +
+ Are you sure you want to delete your account? +
+ + +
+
+
+
+ ); +}; + const UserSettingsPage = ({ user }: userSettingsPageProps) => { + const [isModalOpen, setIsModalOpen] = useState(false); + const deleteFormRef = useRef(null); const { data: insightsUser, mutate } = useFetchUser(user?.user_metadata.user_name, { revalidateOnFocus: false, }); @@ -434,6 +478,11 @@ const UserSettingsPage = ({ user }: userSettingsPageProps) => { action="/api/delete-account" method="POST" className="flex flex-col order-first gap-6 md:order-last" + ref={deleteFormRef} + onSubmit={(e) => { + setIsModalOpen(true); + e.preventDefault(); + }} >
@@ -453,6 +502,14 @@ const UserSettingsPage = ({ user }: userSettingsPageProps) => { > Delete Account + { + setIsModalOpen(false); + deleteFormRef.current?.submit(); + }} + /> )}