From 68dcfcd451b4ffd4b52d822f4bd8227ce3bb23e2 Mon Sep 17 00:00:00 2001 From: Lakhan Baheti <94619783+1akhanBaheti@users.noreply.github.com> Date: Thu, 7 Dec 2023 17:31:58 +0530 Subject: [PATCH] fix: deactivate account post loading (#3022) --- web/components/account/deactivate-account-modal.tsx | 7 ++++++- web/components/onboarding/switch-delete-account-modal.tsx | 6 ++++-- web/store/user.store.ts | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/web/components/account/deactivate-account-modal.tsx b/web/components/account/deactivate-account-modal.tsx index 260526275..f17d0554b 100644 --- a/web/components/account/deactivate-account-modal.tsx +++ b/web/components/account/deactivate-account-modal.tsx @@ -1,7 +1,9 @@ import React, { useState } from "react"; import { useRouter } from "next/router"; +import { useTheme } from "next-themes"; import { Dialog, Transition } from "@headlessui/react"; import { Trash2 } from "lucide-react"; +import { mutate } from "swr"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; // ui @@ -27,6 +29,7 @@ export const DeactivateAccountModal: React.FC = (props) => { const router = useRouter(); const { setToastAlert } = useToast(); + const { setTheme } = useTheme(); const handleClose = () => { setIsDeactivating(false); @@ -43,8 +46,10 @@ export const DeactivateAccountModal: React.FC = (props) => { title: "Success!", message: "Account deactivated successfully.", }); - handleClose(); + mutate("CURRENT_USER_DETAILS", null); + setTheme("system"); router.push("/"); + handleClose(); }) .catch((err) => setToastAlert({ diff --git a/web/components/onboarding/switch-delete-account-modal.tsx b/web/components/onboarding/switch-delete-account-modal.tsx index f0048fc95..fb8f76eff 100644 --- a/web/components/onboarding/switch-delete-account-modal.tsx +++ b/web/components/onboarding/switch-delete-account-modal.tsx @@ -1,4 +1,4 @@ -import React, {useState } from "react"; +import React, { useState } from "react"; import { useRouter } from "next/router"; import { mutate } from "swr"; import { useTheme } from "next-themes"; @@ -67,8 +67,10 @@ export const SwitchOrDeleteAccountModal: React.FC = (props) => { title: "Success!", message: "Account deleted successfully.", }); - handleClose(); + mutate("CURRENT_USER_DETAILS", null); + setTheme("system"); router.push("/"); + handleClose(); }) .catch((err) => setToastAlert({ diff --git a/web/store/user.store.ts b/web/store/user.store.ts index 4862ecf0e..4766a7189 100644 --- a/web/store/user.store.ts +++ b/web/store/user.store.ts @@ -374,6 +374,9 @@ class UserStore implements IUserStore { deactivateAccount = async () => { try { await this.userService.deactivateAccount(); + this.currentUserError = null; + this.currentUser = null; + this.isUserLoggedIn = false; } catch (error) { throw error; }