mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-22 18:18:45 -06:00
chore: redirect for deletion survey (#2054)
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
This commit is contained in:
committed by
GitHub
parent
336480a338
commit
77e2472175
@@ -41,12 +41,12 @@ interface DeleteAccountModalProps {
|
||||
open: boolean;
|
||||
setOpen: Dispatch<SetStateAction<boolean>>;
|
||||
session: Session;
|
||||
IS_FORMBRICKS_CLOUD: boolean;
|
||||
}
|
||||
|
||||
function DeleteAccountModal({ setOpen, open, session }: DeleteAccountModalProps) {
|
||||
function DeleteAccountModal({ setOpen, open, session, IS_FORMBRICKS_CLOUD }: DeleteAccountModalProps) {
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
const [inputValue, setInputValue] = useState("");
|
||||
|
||||
const handleInputChange = (e) => {
|
||||
setInputValue(e.target.value);
|
||||
};
|
||||
@@ -55,8 +55,14 @@ function DeleteAccountModal({ setOpen, open, session }: DeleteAccountModalProps)
|
||||
try {
|
||||
setDeleting(true);
|
||||
await deleteUserAction();
|
||||
await signOut({ callbackUrl: "/auth/login" });
|
||||
await formbricksLogout();
|
||||
// redirect to account deletion survey in Formbricks Cloud
|
||||
if (IS_FORMBRICKS_CLOUD) {
|
||||
await signOut({ redirect: true });
|
||||
window.location.replace("https://app.formbricks.com/s/clri52y3z8f221225wjdhsoo2");
|
||||
} else {
|
||||
await signOut();
|
||||
}
|
||||
} catch (error) {
|
||||
toast.error("Something went wrong");
|
||||
} finally {
|
||||
@@ -107,7 +113,13 @@ function DeleteAccountModal({ setOpen, open, session }: DeleteAccountModalProps)
|
||||
);
|
||||
}
|
||||
|
||||
export function DeleteAccount({ session }: { session: Session | null }) {
|
||||
export function DeleteAccount({
|
||||
session,
|
||||
IS_FORMBRICKS_CLOUD,
|
||||
}: {
|
||||
session: Session | null;
|
||||
IS_FORMBRICKS_CLOUD: boolean;
|
||||
}) {
|
||||
const [isModalOpen, setModalOpen] = useState(false);
|
||||
|
||||
if (!session) {
|
||||
@@ -116,7 +128,12 @@ export function DeleteAccount({ session }: { session: Session | null }) {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<DeleteAccountModal open={isModalOpen} setOpen={setModalOpen} session={session} />
|
||||
<DeleteAccountModal
|
||||
open={isModalOpen}
|
||||
setOpen={setModalOpen}
|
||||
session={session}
|
||||
IS_FORMBRICKS_CLOUD={IS_FORMBRICKS_CLOUD}
|
||||
/>
|
||||
<p className="text-sm text-slate-700">
|
||||
Delete your account with all personal data. <strong>This cannot be undone!</strong>
|
||||
</p>
|
||||
|
||||
@@ -2,6 +2,7 @@ import AccountSecurity from "@/app/(app)/environments/[environmentId]/settings/p
|
||||
import { getServerSession } from "next-auth";
|
||||
|
||||
import { authOptions } from "@formbricks/lib/authOptions";
|
||||
import { IS_FORMBRICKS_CLOUD } from "@formbricks/lib/constants";
|
||||
import { getUser } from "@formbricks/lib/user/service";
|
||||
import { SettingsId } from "@formbricks/ui/SettingsId";
|
||||
|
||||
@@ -36,7 +37,7 @@ export default async function ProfileSettingsPage({ params }: { params: { enviro
|
||||
<SettingsCard
|
||||
title="Delete account"
|
||||
description="Delete your account with all of your personal information and data.">
|
||||
<DeleteAccount session={session} />
|
||||
<DeleteAccount session={session} IS_FORMBRICKS_CLOUD={IS_FORMBRICKS_CLOUD} />
|
||||
</SettingsCard>
|
||||
<SettingsId title="Profile" id={user.id}></SettingsId>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user