"use client"; import { useEffect, useState } from 'react'; import { useRouter } from 'next/navigation'; import Image from 'next/image'; import Header from '../components/Header'; import logo from '../logo.svg'; const imgLine2 = "http://localhost:3845/assets/6ee8cf4ebb6bc2adb14aab8c9940b3002c20af35.svg"; export default function StudyDataPage() { const router = useRouter(); const [isLoggedIn, setIsLoggedIn] = useState(false); const [isLoading, setIsLoading] = useState(true); const [curriculums, setCurriculums] = useState([]); useEffect(() => { // 로그인 상태 확인 const loginStatus = localStorage.getItem('isLoggedIn') === 'true'; setIsLoggedIn(loginStatus); setIsLoading(false); // TODO: DB에서 교육 과정 목록 가져오기 // const fetchCurriculums = async () => { // const response = await fetch('/api/curriculums'); // const data = await response.json(); // setCurriculums(data); // }; // fetchCurriculums(); }, []); if (isLoading) { return null; // 로딩 중 } // 로그인되지 않았으면 로그인 페이지로 리다이렉트 if (!isLoggedIn) { router.push('/login'); return null; } return (
{/* 헤더 */}
{/* 구분선 */}
{/* 메인 콘텐츠 */}
{/* 페이지 제목 */}

학습 자료 ({curriculums.length}건)

{/* 테이블 헤더 */}

제목

등록자

등록일

{/* 테이블 내용 */} {curriculums.length > 0 ? (
{curriculums.map((curriculum) => (

{curriculum.title}

{curriculum.instructorName || '-'}

{curriculum.createdAt ? new Date(curriculum.createdAt).toLocaleDateString('ko-KR') : '-'}

))}
) : (

등록된 학습 자료가 없습니다.

)}
{/* 푸터 */}
); }