diff --git a/src/app/admin/certificates/page.tsx b/src/app/admin/certificates/page.tsx
index 87a64db..1c0f92f 100644
--- a/src/app/admin/certificates/page.tsx
+++ b/src/app/admin/certificates/page.tsx
@@ -1,8 +1,22 @@
'use client';
+import { useState, useMemo } from "react";
import AdminSidebar from "@/app/components/AdminSidebar";
+import ChevronDownSvg from "@/app/svgs/chevrondownsvg";
export default function AdminCertificatesPage() {
+ // TODO: 나중에 실제 데이터로 교체
+ const items: any[] = [];
+ const [currentPage, setCurrentPage] = useState(1);
+
+ const ITEMS_PER_PAGE = 10;
+ const totalPages = Math.ceil(items.length / ITEMS_PER_PAGE);
+ const paginatedItems = useMemo(() => {
+ const startIndex = (currentPage - 1) * ITEMS_PER_PAGE;
+ const endIndex = startIndex + ITEMS_PER_PAGE;
+ return items.slice(startIndex, endIndex);
+ }, [items, currentPage]);
+
return (
{/* 메인 레이아웃 */}
@@ -25,6 +39,101 @@ export default function AdminCertificatesPage() {
{/* 콘텐츠 영역 */}
+ {items.length === 0 ? (
+
+
+ 현재 관리할 수 있는 항목이 없습니다.
+
+
+ ) : (
+ <>
+ {/* TODO: 테이블 또는 리스트를 여기에 추가 */}
+
+ {/* 페이지네이션 - 10개 초과일 때만 표시 */}
+ {items.length > ITEMS_PER_PAGE && (() => {
+ // 페이지 번호를 10단위로 표시
+ const pageGroup = Math.floor((currentPage - 1) / 10);
+ const startPage = pageGroup * 10 + 1;
+ const endPage = Math.min(startPage + 9, totalPages);
+ const visiblePages = Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i);
+
+ return (
+
+
+ {/* First (맨 앞으로) */}
+
+
+ {/* Prev */}
+
+
+ {/* Numbers */}
+ {visiblePages.map((n) => {
+ const active = n === currentPage;
+ return (
+
+ );
+ })}
+
+ {/* Next */}
+
+
+ {/* Last (맨 뒤로) */}
+
+
+
+ );
+ })()}
+ >
+ )}
diff --git a/src/app/admin/courses/CourseRegistrationModal.tsx b/src/app/admin/courses/CourseRegistrationModal.tsx
index cc0d765..917f1c7 100644
--- a/src/app/admin/courses/CourseRegistrationModal.tsx
+++ b/src/app/admin/courses/CourseRegistrationModal.tsx
@@ -3,17 +3,21 @@
import React, { useState, useRef, useEffect, useMemo } from "react";
import ModalCloseSvg from "@/app/svgs/closexsvg";
import DropdownIcon from "@/app/svgs/dropdownicon";
-import { getInstructors, type UserRow } from "@/app/admin/id/page";
+import { getInstructors, type UserRow } from "@/app/admin/id/mockData";
+import { type Course } from "./mockData";
type Props = {
open: boolean;
onClose: () => void;
+ onSave?: (courseName: string, instructorName: string) => void;
+ editingCourse?: Course | null;
};
-export default function CourseRegistrationModal({ open, onClose }: Props) {
+export default function CourseRegistrationModal({ open, onClose, onSave, editingCourse }: Props) {
const [courseName, setCourseName] = useState("");
const [instructorId, setInstructorId] = useState("");
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
+ const [errors, setErrors] = useState>({});
const dropdownRef = useRef(null);
const modalRef = useRef(null);
@@ -28,6 +32,23 @@ export default function CourseRegistrationModal({ open, onClose }: Props) {
return instructors.find(inst => inst.id === instructorId);
}, [instructors, instructorId]);
+ // 수정 모드일 때 기존 데이터 채우기
+ useEffect(() => {
+ if (open && editingCourse) {
+ setCourseName(editingCourse.courseName);
+ // 강사명으로 instructorId 찾기
+ const instructor = instructors.find(inst => inst.name === editingCourse.instructorName);
+ if (instructor) {
+ setInstructorId(instructor.id);
+ }
+ } else if (!open) {
+ setCourseName("");
+ setInstructorId("");
+ setIsDropdownOpen(false);
+ setErrors({});
+ }
+ }, [open, editingCourse, instructors]);
+
// 외부 클릭 시 드롭다운 닫기
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
@@ -53,6 +74,28 @@ export default function CourseRegistrationModal({ open, onClose }: Props) {
e.stopPropagation();
};
+ // 저장 버튼 클릭 핸들러
+ const handleSave = () => {
+ const nextErrors: Record = {};
+
+ if (!courseName.trim()) {
+ nextErrors.courseName = "교육 과정명을 입력해 주세요.";
+ }
+ if (!instructorId || !selectedInstructor) {
+ nextErrors.instructor = "강사를 선택해 주세요.";
+ }
+
+ setErrors(nextErrors);
+
+ if (Object.keys(nextErrors).length > 0) {
+ return;
+ }
+
+ if (onSave && selectedInstructor) {
+ onSave(courseName.trim(), selectedInstructor.name);
+ }
+ };
+
if (!open) return null;
return (
@@ -74,7 +117,7 @@ export default function CourseRegistrationModal({ open, onClose }: Props) {
{/* Header */}
- 과목 등록
+ {editingCourse ? "교육과정 수정" : "과목 등록"}
{/* 강사 */}
@@ -112,7 +171,11 @@ export default function CourseRegistrationModal({ open, onClose }: Props) {