Skip to content

Commit 639531f

Browse files
update profile delete mechanism
1 parent 30b82bc commit 639531f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

frontend/src/app/settings/page.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ import { ChangeEvent, useEffect, useState } from "react";
33
import { BiUserCircle } from "@react-icons/all-files/bi/BiUserCircle";
44
import {
55
deleteProfileUrl,
6-
deleteQuestionUrl,
76
fetchProfileUrl,
87
updateProfileUrl,
98
} from "../api";
109
import useLogin from "../hooks/useLogin";
1110
import { message } from "antd";
1211
import { useMutation } from "@tanstack/react-query";
13-
import { getAuth, signOut } from "firebase/auth";
12+
import { deleteUser, getAuth } from "firebase/auth";
1413
import { useRouter } from "next/navigation";
1514

1615
const SettingPage = () => {
@@ -25,10 +24,11 @@ const SettingPage = () => {
2524
content: "Successfully deleted profile! Logging you out...",
2625
});
2726
const auth = getAuth();
28-
setTimeout(() => {
29-
signOut(auth);
30-
router.push("/");
31-
}, 2000);
27+
if (auth.currentUser) {
28+
deleteUser(auth.currentUser).then(() => {
29+
router.push("/");
30+
});
31+
}
3232
},
3333
onError: (e) => {
3434
api.open({
@@ -44,7 +44,7 @@ const SettingPage = () => {
4444
setPreferredLang(res.payload.preferredLang);
4545
setName(res.payload.name || "");
4646
});
47-
}, [deleteProfileMutation.status]);
47+
}, []);
4848

4949
const [api, contextHolder] = message.useMessage();
5050

0 commit comments

Comments
 (0)