Skip to content

Commit 98aefd0

Browse files
authored
Merge pull request #220 from Soohyuniii/feat/탈퇴-기능-작업
feat: 탈퇴 api 연동
2 parents d9d2c59 + a63f53e commit 98aefd0

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/api/user.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { authInstance } from "@/api/axios";
2+
3+
export const deleteUser = async () => {
4+
const response = await authInstance.delete("/api/users");
5+
return response.data;
6+
};

src/pages/MyInfo.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import useAuthStore from "@/store/useAuthStore";
55
import { useNavigate } from "react-router-dom";
66
import TermsAndPrivacyModal from "@/components/modal/TermsAndPrivacyModal";
77
import { trackEvent } from "@/libs/analytics";
8+
import { deleteUser } from "@/api/user";
89

910
type ModalType = "logout" | "withdraw" | "terms" | "privacy" | null;
1011

@@ -32,7 +33,7 @@ const MyInfo = () => {
3233
setModalType(null);
3334
};
3435

35-
const handleConfirm = () => {
36+
const handleConfirm = async () => {
3637
if (modalType === "logout") {
3738
trackEvent("Click", {
3839
page: "내 정보",
@@ -45,7 +46,15 @@ const MyInfo = () => {
4546
page: "내 정보",
4647
element: "회원탈퇴"
4748
});
48-
console.log("회원탈퇴 실행"); //TODO: 회원탈퇴 기능 구현 시 추가 필요
49+
50+
try {
51+
await deleteUser();
52+
logout();
53+
navigate("/");
54+
} catch (error) {
55+
console.error(error);
56+
navigate("/error");
57+
}
4958
}
5059
setModalType(null);
5160
};

0 commit comments

Comments
 (0)