Skip to content
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
26 changes: 25 additions & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"immer": "^10.2.0",
"lucide-react": "^0.555.0",
"pretendard": "^1.3.9",
"qrcode.react": "^4.2.0",
"react": "^19.1.1",
"react-day-picker": "^9.11.1",
"react-dom": "^19.1.1",
Expand Down
35 changes: 22 additions & 13 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ import MonthlyReportDetail from './pages/external/MonthlyReportDetail.jsx';
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';

import ProtectedRoute from './components/protectedRoute.jsx';

function App() {
return (
<>
<Routes>
{/* Public */}
<Route path="/main" element={<Main />} />
<Route path="/main/intro" element={<Intro />} />
<Route path="/main/leaders" element={<Leaders />} />
Expand All @@ -39,24 +42,30 @@ function App() {
path="/main/monthly-report-detail"
element={<MonthlyReportDetail />}
/>

<Route path="/login" element={<Login />} />
<Route path="/signup" element={<SignUp />} />
<Route path="/oauth/success" element={<OAuthSuccess />} />
<Route element={<Layout />}>
<Route path="/" element={<Home />} />
<Route path="/attendance" element={<Attendance />} />
<Route path="/attendance-manage" element={<AttendanceManage />} />
<Route path="/board" element={<Board />} />
<Route path="/board/:team" element={<Board />} />
<Route path="/board/:team/:postId" element={<PostDetail />} />
<Route path="/board/:team/post/:postId" element={<PostDetail />} />
<Route path="/quant-bot" element={<QuantTradingDashboard />} />
<Route path="/stock-game" element={<StockGame />} />
<Route path="/backtest" element={<BackTest />} />
<Route path="/backtest/result" element={<BacktestResult />} />
<Route path="/mypage" element={<Mypage />} />

{/* Protected */}
<Route element={<ProtectedRoute />}>
<Route element={<Layout />}>
<Route path="/" element={<Home />} />
<Route path="/attendance" element={<Attendance />} />
<Route path="/attendance-manage" element={<AttendanceManage />} />
<Route path="/board" element={<Board />} />
<Route path="/board/:team" element={<Board />} />
<Route path="/board/:team/:postId" element={<PostDetail />} />
<Route path="/board/:team/post/:postId" element={<PostDetail />} />
<Route path="/quant-bot" element={<QuantTradingDashboard />} />
<Route path="/stock-game" element={<StockGame />} />
<Route path="/backtest" element={<BackTest />} />
<Route path="/backtest/result" element={<BacktestResult />} />
<Route path="/mypage" element={<Mypage />} />
</Route>
</Route>
</Routes>

<ToastContainer
position="top-center"
autoClose={2000}
Expand Down
44 changes: 9 additions & 35 deletions frontend/src/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,18 @@ import Logo from '../assets/logo.png';
import { useState, useEffect } from 'react';
import { api } from '../utils/axios';
import { toast } from 'react-toastify';
import { useAuth } from '../contexts/AuthContext';

const Header = ({ isRoot, onToggleSidebar, isOpen }) => {
const nav = useNavigate();
const location = useLocation();
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [loading, setLoading] = useState(true);
const { isLoggedIn, logout } = useAuth();

// 로그인 상태 확인 - location 변경 시마다 재확인
useEffect(() => {
const checkLoginStatus = async () => {
try {
await api.get('/api/user/details');
setIsLoggedIn(true);
} catch (error) {
setIsLoggedIn(false);
} finally {
setLoading(false);
}
};

checkLoginStatus();
}, [location.pathname]);

const logout = async () => {
try {
await api.post('/api/auth/logout');
} catch (error) {
console.log('로그아웃 API 호출 실패:', error.message);
} finally {
// localStorage 유저 정보 삭제
localStorage.removeItem('user');

setIsLoggedIn(false);
nav('/');
toast.success('로그아웃 되었습니다.');
}
const handleLogout = async () => {
await logout();
toast.success('로그아웃 되었습니다.');
navigate('/');
};

return (
<header className={`${styles.header} ${isRoot ? styles.transparent : ''}`}>
{/* 모바일/태블릿에서는 항상 햄버거 버튼 표시 */}
Expand All @@ -55,15 +29,15 @@ const Header = ({ isRoot, onToggleSidebar, isOpen }) => {
<span></span>
<span></span>
</button>

<div className={styles.brand} onClick={() => nav('/')}>
<img className={styles.logo} src={Logo} alt="세종투자연구회 로고" />
<span className={styles.title}>세종투자연구회</span>
</div>

<div className={styles.authLinks}>
{isLoggedIn ? (
<button onClick={logout} className={styles.logoutButton}>
<button onClick={handleLogout} className={styles.logoutButton}>
로그아웃
</button>
) : (
Expand Down
53 changes: 10 additions & 43 deletions frontend/src/components/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styles from './Sidebar.module.css';
import { useState, useEffect } from 'react';
import { api } from '../utils/axios';
import { toast } from 'react-toastify';
import { useAuth } from '../contexts/AuthContext';

const Sidebar = ({ isOpen, isRoot, onClose }) => {
const navigate = useNavigate();
Expand All @@ -25,40 +26,12 @@ const Sidebar = ({ isOpen, isRoot, onClose }) => {
const [selectedBoard, setSelectedBoard] = useState(
currentBoard?.name || '전체 게시판'
);
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [loading, setLoading] = useState(true);
const { isLoggedIn, logout } = useAuth();

// 로그인 상태 확인 - location 변경 시마다 재확인
useEffect(() => {
const checkLoginStatus = async () => {
try {
await api.get('/api/user/details');
setIsLoggedIn(true);
} catch (error) {
setIsLoggedIn(false);
} finally {
setLoading(false);
}
};

checkLoginStatus();
}, [location.pathname]); // location 변경 시마다 확인

const logout = async () => {
try {
await api.post('/api/auth/logout');
} catch (error) {
// 로그아웃 API 실패해도 무시 (토큰이 없을 수 있음)
console.log('로그아웃 API 호출 실패:', error.message);
} finally {
// localStorage 유저 정보 삭제
localStorage.removeItem('user');

// API 성공 여부와 관계없이 항상 로그아웃 처리
setIsLoggedIn(false);
navigate('/');
toast.success('로그아웃 되었습니다.');
}
const handleLogout = async () => {
await logout();
toast.success('로그아웃 되었습니다.');
navigate('/');
};

const handleNavLinkClick = () => {
Expand All @@ -72,13 +45,9 @@ const Sidebar = ({ isOpen, isRoot, onClose }) => {
<>
{/* 모바일 오버레이 */}
{isOpen && (
<div
className={styles.overlay}
onClick={onClose}
aria-hidden="true"
/>
<div className={styles.overlay} onClick={onClose} aria-hidden="true" />
)}

{/* 사이드바 */}
<div
className={`${styles.homeSidebarMenu} ${
Expand Down Expand Up @@ -187,9 +156,7 @@ const Sidebar = ({ isOpen, isRoot, onClose }) => {
<NavLink
to="/mypage"
className={({ isActive }) =>
isActive
? styles['active-link']
: styles['inactive-link']
isActive ? styles['active-link'] : styles['inactive-link']
}
onClick={handleNavLinkClick}
>
Expand All @@ -204,7 +171,7 @@ const Sidebar = ({ isOpen, isRoot, onClose }) => {
className={styles['inactive-link']}
onClick={(e) => {
e.preventDefault();
logout();
handleLogoutogout();
handleNavLinkClick();
}}
>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/VerificationModal.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ h1 {
}

.codeInput {
flex: 1;
height: 48px;
display: flex;
height: 30px;
padding: 0 12px;
font-size: 16px;
border-radius: 8px;
Expand Down
Loading