diff --git a/src/Router.js b/src/Router.js index 7be4fec..b2cd353 100644 --- a/src/Router.js +++ b/src/Router.js @@ -17,6 +17,7 @@ import SavedWorkers from './pages/MyPage/SavedWorkers'; import AlbaReviewPage from './pages/AlbaReviewPage'; import MyResume from './pages/MyResume/MyResume'; import MyStoreForm from './pages/MyPage/MyStore/MyStoreForm'; +import SocialLoginCallback from "./pages/SocialLoginCallback"; const AppRouter = () => { return ( @@ -40,6 +41,7 @@ const AppRouter = () => { } /> } /> } /> + } /> ); }; diff --git a/src/components/common/MypageSubMenu.jsx b/src/components/common/MypageSubMenu.jsx index 8d7e6a3..a99dad4 100644 --- a/src/components/common/MypageSubMenu.jsx +++ b/src/components/common/MypageSubMenu.jsx @@ -1,5 +1,5 @@ -import React, { useState, useEffect } from "react"; -import { useLocation } from "react-router-dom"; +import React, { useState, useEffect, useMemo } from "react"; +import { useLocation, useNavigate } from "react-router-dom"; import { Link } from "react-router-dom"; import styled from "styled-components"; @@ -12,8 +12,11 @@ import { BsBookmarkFill } from "react-icons/bs"; const MypageSubMenu = ({ userType }) => { const location = useLocation(); // 현재 경로 가져오기 + const navigate = useNavigate(); const [activeMenu, setActiveMenu] = useState(null); + + // 알바생과 사장님의 공통 메뉴 항목 const commonMenu = [ { name: '체결 현황', path: '/mypage/contracts', icon: }, @@ -34,17 +37,24 @@ const MypageSubMenu = ({ userType }) => { ...commonMenu ]; - // 사용자 타입에 맞는 메뉴 선택 - const menuItems = userType === 'worker' ? workerMenu : ownerMenu; - - // 초기 activeMenu를 현재 경로로 설정 + const menuItems = useMemo(() => { + if (!userType) return []; + return userType === "worker" ? workerMenu : ownerMenu; + }, [userType]); + useEffect(() => { + if (!userType || menuItems.length === 0) return; + const currentPath = location.pathname; const activeItem = menuItems.find((item) => item.path === currentPath); - if (activeItem) { + + if (activeItem && activeMenu !== activeItem.name) { setActiveMenu(activeItem.name); + } else if (!activeItem && activeMenu !== menuItems[0].name) { + setActiveMenu(menuItems[0].name); + navigate(menuItems[0].path, { replace: true }); } - }, [location.pathname, menuItems]); + }, [location.pathname, userType, menuItems, activeMenu, navigate]); // 메뉴 항목 클릭 시 activeMenu 상태 업데이트 diff --git a/src/components/layout/Header.jsx b/src/components/layout/Header.jsx index d423eab..2b19f96 100644 --- a/src/components/layout/Header.jsx +++ b/src/components/layout/Header.jsx @@ -60,7 +60,17 @@ function Header() { 알바찾기 알바후기 고객지원 - 마이페이지 + { + if (!isAuthenticated) { + e.preventDefault(); // ✅ 기본 이동 동작 막기 + alert("로그인 후 이용해주세요."); + } + }} + > + 마이페이지 + {isAuthenticated ? ( diff --git a/src/pages/LoginModal.jsx b/src/pages/LoginModal.jsx index ae9dca6..a32318f 100644 --- a/src/pages/LoginModal.jsx +++ b/src/pages/LoginModal.jsx @@ -46,6 +46,10 @@ function LoginModal({ onClose }) { } }; + const handleSocialLogin = (provider) => { + window.location.href = `https://www.danpat.store/oauth2/authorization/${provider}`; + }; + return ( @@ -100,8 +104,8 @@ function LoginModal({ onClose }) {
- - + handleSocialLogin("naver")} /> + handleSocialLogin("kakao")} />
)} diff --git a/src/pages/SignUpModal.jsx b/src/pages/SignUpModal.jsx index 39b3b34..2db2c5c 100644 --- a/src/pages/SignUpModal.jsx +++ b/src/pages/SignUpModal.jsx @@ -18,31 +18,35 @@ function SignUpModal({ onClose }) { onClose(); }; + const handleSocialSignUp = (provider) => { + window.location.href = `https://www.danpat.store/oauth2/authorization/${provider}`; + }; + return ( - handleSignUp('worker')}> +
worker 개인 회원

원하는 시간, 딱 맞는 알바,
지금 시작해보세요!

-