Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#117 프로필-로그아웃 개발 #125

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion FITple-Frontend/data/LoginApi.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const login = async (loginId, loginPw) => {
}
};


export const findId = async (name, email) => {
try {
const response = await fetch(`${localhost}/FITple/auth/find-id`, {
Expand Down
11 changes: 10 additions & 1 deletion FITple-Frontend/src/pages/ProfilePage/ProfilePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useNavigate } from "react-router-dom";
import { getProfile } from "../../../data/GetProfileApi";
import useAuthStore from "../../../data/store/userAuthStore";
import { useEffect } from "react";
import { logout } from "../../../data/LoginApi"; // 로그아웃 API를 가져옵니다.

const ProfilePage = () => {
const navigate = useNavigate();
Expand Down Expand Up @@ -57,6 +58,14 @@ const ProfilePage = () => {
getProfileData();
}, []);

// 로그아웃 핸들러 함수 추가
const handleLogout = () => {
console.log("현재 토큰:", useAuthStore.getState().token); // 현재 토큰 확인
useAuthStore.setState({ token: null });
console.log("현재 토큰:", useAuthStore.getState().token); // 현재 토큰 확인
navigate("/"); // "/"로 리다이렉트
};

return (
<>
{/* 위에 box */}
Expand All @@ -81,7 +90,7 @@ const ProfilePage = () => {
>
문의하기
</OptionItem>
<OptionItem $last>로그아웃</OptionItem>
<OptionItem $last onClick={handleLogout}>로그아웃</OptionItem>
</OptionBox>
</ProfileBox>
</ProfileContainer>
Expand Down