Skip to content

Commit

Permalink
Fix: 로그아웃 시 API 요청 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sscoderati committed Jan 9, 2024
1 parent 80684e2 commit ac0ffee
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/pages/profile/ProfileDefault.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,20 @@ const ProfileDefault = () => {
openModal({
mainText: "로그아웃 하시겠습니까?",
subText: "로그아웃 시 로그인 화면으로 이동합니다.",
okFunc: () => {
// TODO: 명령형 -> 선언형 로직으로 변경
localStorage.setItem("jwt", "");
localStorage.removeItem("userId");
localStorage.removeItem("nickname");
localStorage.removeItem("profileImageUrl");
useAuthStore.persist.clearStorage();
navigate("/login");
okFunc: async () => {
await axiosAPI
.post("/v1/auth/logout")
.then(() => {
localStorage.setItem("jwt", "");
localStorage.removeItem("userId");
localStorage.removeItem("nickname");
localStorage.removeItem("profileImageUrl");
useAuthStore.persist.clearStorage();
navigate("/login");
})
.catch((err) => {
console.log(err);
});
},
type: "warn",
acceptText: "네, 로그아웃 하겠습니다.",
Expand Down

0 comments on commit ac0ffee

Please sign in to comment.