diff --git a/src/components/global/token/tokenManagement.jsx b/src/components/global/token/tokenManagement.jsx index 62fa5555..39392fd4 100644 --- a/src/components/global/token/tokenManagement.jsx +++ b/src/components/global/token/tokenManagement.jsx @@ -20,7 +20,7 @@ const fetchToken = async (code) => { 'Content-Type': 'application/json', }, }); - console.log(response); + if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } @@ -44,13 +44,11 @@ const TokenManagement = () => { console.log('role:', role); if (!code || !role) { - console.error('코드 또는 역할이 URL에 포함되어 있지 않습니다.'); navigate('/login'); return; } if (role === 'GUEST') { - console.log('약관 동의 페이지로 이동합니다.'); navigate('/login/terms', { state: {code} }); } else { fetchToken(code) @@ -70,7 +68,6 @@ const TokenManagement = () => { const decoded = decodeToken(accessToken); if (['MEMBER', 'PREMIUM', 'ADMIN'].includes(decoded.role)) { - console.log('회원 정보가 존재합니다. 메인 페이지로 이동합니다.'); navigate(prevPage || '/'); initializeSSE(queryClient, dispatch); } else { diff --git a/src/components/pages/myPage/secessionPage.tsx b/src/components/pages/myPage/secessionPage.tsx index 895c5bf1..666f6c54 100644 --- a/src/components/pages/myPage/secessionPage.tsx +++ b/src/components/pages/myPage/secessionPage.tsx @@ -9,6 +9,10 @@ import TabBar from '../../ui/tabBar/tabBar'; import SecessionWarning from '../../../asset/image/secessionWarning.svg'; import { fetchAPI } from '../../global/utils/apiUtil.js'; import { showErrorToast, showSuccessToast } from '../../ui/toast/toast.tsx'; +import {ACCESS_TOKEN, REFRESH_TOKEN} from '../../global/constants/index.ts' +import {alertCount} from '../../../store/actions/alertActions.js' +import { useDispatch } from 'react-redux'; +import {setLoggedIn} from'../../../store/actions/userActions'; const Divider = styled.div` height: 0.3rem; @@ -20,6 +24,7 @@ const Divider = styled.div` function SecessionPage() { const navigate = useNavigate(); const location = useLocation(); + const dispatch = useDispatch(); const { nickname } = location.state as { nickname: string }; const [isAgreed, setIsAgreed] = useState(false); const [secessionReason, setSecessionReason] = useState(''); @@ -49,7 +54,11 @@ function SecessionPage() { try { await fetchAPI('/api/member/leave', 'DELETE'); showSuccessToast('성공적으로 탈퇴 처리되었습니다.'); - navigate('/'); + localStorage.removeItem(ACCESS_TOKEN); + localStorage.removeItem(REFRESH_TOKEN); + dispatch(setLoggedIn(false)); + dispatch(alertCount(0)); + navigate('/secessionComplete-page'); } catch (error) { showErrorToast(`탈퇴 처리 중 오류가 발생했습니다: ${error}`); } diff --git a/src/components/pages/termsPage/termsPage.tsx b/src/components/pages/termsPage/termsPage.tsx index f3d4fa00..d5d7e0de 100644 --- a/src/components/pages/termsPage/termsPage.tsx +++ b/src/components/pages/termsPage/termsPage.tsx @@ -37,7 +37,7 @@ export default function TermsPage() { const queryClient = useQueryClient(); const dispatch = useDispatch(); const { code } = location.state as LocationState; - console.log("코드",code) + // =========================================================== 약관 동의 확인을 위한 부분 const [allAgreed, setAllAgreed] = useState(false); const [termsAgreement, setTermsAgreement] = useState({