diff --git a/frontend/package.json b/frontend/package.json
index d552f49..56b3680 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -16,7 +16,7 @@
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
- "proxy": "http://localhost:8080",
+ "proxy": "http://13.209.73.127:8080",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
@@ -41,4 +41,4 @@
"last 1 safari version"
]
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/pages/login/LoginPage.js b/frontend/src/pages/login/LoginPage.js
index 930239a..a232d89 100644
--- a/frontend/src/pages/login/LoginPage.js
+++ b/frontend/src/pages/login/LoginPage.js
@@ -3,19 +3,19 @@ import { useNavigate } from 'react-router-dom'; // 추가
import styles from './LoginPage.module.css';
function LoginPage() {
- const navigate = useNavigate();
+ const navigate = useNavigate();
const [focused, setFocused] = useState('');
- const [form, setForm] = useState({ name: '', password: '' });
+ const [form, setForm] = useState({ name: '', password: '' });
+
-
const handleChange = (e) => {
setForm({ ...form, [e.target.name]: e.target.value });
};
-
+
const handleLogin = async () => {
try {
- const response = await fetch('/api/login', {
+ const response = await fetch('/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(form),
@@ -24,8 +24,8 @@ function LoginPage() {
if (response.ok) {
const data = await response.json();
localStorage.setItem('token', data.token);
- localStorage.setItem('role', data.role);
- navigate('/home');
+ localStorage.setItem('role', data.role);
+ navigate('/sessions'); // 로그인 성공 시 이동할 페이지
} else {
alert('이름 또는 비밀번호가 올바르지 않습니다.');
}
@@ -40,25 +40,25 @@ function LoginPage() {
setFocused('name')}
onBlur={() => setFocused('')}
/>
setFocused('pw')}
onBlur={() => setFocused('')}
/>
-
+
);
diff --git a/frontend/src/pages/qna/QnAMainPage.js b/frontend/src/pages/qna/QnAMainPage.js
index d01df87..4e611ea 100644
--- a/frontend/src/pages/qna/QnAMainPage.js
+++ b/frontend/src/pages/qna/QnAMainPage.js
@@ -1,55 +1,121 @@
+import { useState, useEffect } from 'react';
import styles from './QnAMainPage.module.css';
import { FiLogIn } from 'react-icons/fi';
-const nowSessions = [ // css 보려고 걍 적어둠
- { id: 1, icon: '☀', title: 'HTML/CSS', week: '1주차 화요일 오전', date: '2026.04.19', time: '10:00 ~ 13:00' }
-];
+// ─────────────────────────────────────────────
+// 📌 목업 데이터
+// ─────────────────────────────────────────────
+// const MOCK_DATA = {
+// activeSessions: [
+// { sessionId: 1, week: 1, dayOfWeek: '화요일', dayPart: '오전', sessionDate: '2026.05.23', title: 'HTML/CSS' }
+// ],
+// pastSessions: [
+// { sessionId: 1, week: 1, dayOfWeek: '화요일', dayPart: '오전', sessionDate: '2026.05.23', title: 'HTML/CSS' },
+// { sessionId: 2, week: 1, dayOfWeek: '화요일', dayPart: '오후', sessionDate: '2026.05.23', title: 'Git 기초' },
+// ]
+// };
+// ─────────────────────────────────────────────
-const pastSessions = [ // css 보려고 걍 적어둠
- { id: 1, icon: '☀', title: 'HTML/CSS', week: '1주차 화요일 오전' },
- { id: 2, icon: '☾', title: 'Git 기초', week: '1주차 화요일 오후' },
- { id: 3, icon: '☀', title: 'HTML/CSS', week: '1주차 화요일 오전' },
- { id: 4, icon: '☾', title: 'Git 기초', week: '1주차 화요일 오후' },
- { id: 5, icon: '☀', title: 'HTML/CSS', week: '1주차 화요일 오전' },
- { id: 6, icon: '☾', title: 'Git 기초', week: '1주차 화요일 오후' },
-];
+const BASE_URL = '';
+
+const getIcon = (dayPart) => dayPart === '오전' ? '☀' : '☾';
+const getTime = (dayPart) => dayPart === '오전' ? '10:00 ~ 13:00' : '14:00 ~ 17:00';
function QNAMainPage() {
+ const [activeSessions, setActiveSessions] = useState([]);
+ const [pastSessions, setPastSessions] = useState([]);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState(null);
+
+ useEffect(() => {
+ const fetchSessions = async () => {
+ try {
+ setLoading(true);
+
+ const token = localStorage.getItem('token');
+
+ const res = await fetch(`${BASE_URL}/api/sessions`, {
+ method: 'GET',
+ headers: {
+ 'Authorization': `Bearer ${token}`,
+ 'Content-Type': 'application/json',
+ }
+ });
+
+ if (!res.ok) throw new Error(`서버 오류: ${res.status}`);
+
+ const json = await res.json();
+
+ if (!json.isSuccess) throw new Error(json.message);
+
+ // DB에 데이터 없으면 목업으로 대체
+ // setActiveSessions(json.result.activeSessions.length > 0 ? json.result.activeSessions : MOCK_DATA.activeSessions);
+ // setPastSessions(json.result.pastSessions.length > 0 ? json.result.pastSessions : MOCK_DATA.pastSessions);
+
+ } catch (err) {
+ console.error('세션 불러오기 실패:', err);
+ // setActiveSessions(MOCK_DATA.activeSessions);
+ // setPastSessions(MOCK_DATA.pastSessions);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchSessions();
+ }, []);
+
+ if (loading) return 불러오는 중...
;
+ if (error) return 오류: {error}
;
return (
-
- Q&A
- {nowSessions.map(session => (
-
-
- {session.icon}
- {session.title}
-
-
{session.week}
-
{session.date}
-
{session.time}
+
+ {/* 진행 중인 세션 있을 때만 표시 */}
+ {activeSessions.length > 0 && (
+ <>
+
+ Q&A
+ {activeSessions.map(session => (
+
+
+ {getIcon(session.dayPart)}
+ {session.title}
+
+
{session.week}주차 {session.dayOfWeek} {session.dayPart}
+
{session.sessionDate}
+
{getTime(session.dayPart)}
+
+ ))}
+
+
+ >
+ )}
+
+ {/* 지난 세션 */}
+ {pastSessions.length > 0 ? (
+
+ 지난 세션
+
+ {pastSessions.map(session => (
+
+
+ {getIcon(session.dayPart)}
+ {session.title}
+ •{session.week}주차 {session.dayOfWeek} {session.dayPart}
+
+
+
+ ))}
- ))}
-
-
-
-
-
- 지난 세션
-
- {pastSessions.map(session => (
-
-
- {session.icon}
- {session.title}
- •{session.week}
-
-
-
- ))}
-
-
+
+ ) : (
+ /* 진행 중인 세션도 없고 지난 세션도 없을 때 */
+ activeSessions.length === 0 && (
+
+ )
+ )}
);
diff --git a/frontend/src/pages/qna/QnAMainPage.module.css b/frontend/src/pages/qna/QnAMainPage.module.css
index cc883c3..655d5cb 100644
--- a/frontend/src/pages/qna/QnAMainPage.module.css
+++ b/frontend/src/pages/qna/QnAMainPage.module.css
@@ -126,4 +126,10 @@
.listItem:hover .enterBtn {
color: var(--dark);
+}
+
+.empty {
+ text-align: center;
+ color: #888;
+ margin-top: 40px;
}
\ No newline at end of file