회원 불러오기 작업하는 중1

This commit is contained in:
2025-11-26 21:40:56 +09:00
parent 47eedf6837
commit 53a5713ddd
12 changed files with 494 additions and 809 deletions

View File

@@ -24,10 +24,27 @@ export default function CourseRegistrationModal({ open, onClose, onSave, onDelet
const modalRef = useRef<HTMLDivElement>(null);
// 강사 목록 가져오기
// TODO: 나중에 DB에서 가져오도록 변경 시 async/await 사용
// 예: const [instructors, setInstructors] = useState<UserRow[]>([]);
// useEffect(() => { getInstructors().then(setInstructors); }, []);
const instructors = useMemo(() => getInstructors(), []);
const [instructors, setInstructors] = useState<UserRow[]>([]);
const [isLoadingInstructors, setIsLoadingInstructors] = useState(false);
useEffect(() => {
async function loadInstructors() {
setIsLoadingInstructors(true);
try {
const data = await getInstructors();
setInstructors(data);
} catch (error) {
console.error('강사 목록 로드 오류:', error);
setInstructors([]);
} finally {
setIsLoadingInstructors(false);
}
}
if (open) {
loadInstructors();
}
}, [open]);
// 선택된 강사 정보
const selectedInstructor = useMemo(() => {

View File

@@ -1,5 +1,3 @@
import { getInstructors } from "@/app/admin/id/mockData";
export type Course = {
id: string;
courseName: string;
@@ -12,17 +10,22 @@ export type Course = {
// TODO: 나중에 DB에서 가져오도록 변경
export const MOCK_CURRENT_USER = "관리자"; // 현재 로그인한 사용자 이름
// 강사 목록 가져오기
const instructors = getInstructors();
const instructorNames = instructors.map(instructor => instructor.name);
// TODO: 이 부분도 나중에는 db에서 받아오도록 변경 예정
// 임시 데이터 - 강사명은 mockData.ts의 강사 데이터 활용
// 임시 데이터 - 기본 강사명 목록 (getInstructors는 async이므로 모듈 레벨에서 사용 불가)
const defaultInstructorNames = [
"최예준",
"정시우",
"임건우",
"송윤서",
"김민수",
"정대현",
];
export const MOCK_COURSES: Course[] = [
{
id: "1",
courseName: "웹 개발 기초",
instructorName: instructorNames[0] || "최예준",
instructorName: defaultInstructorNames[0] || "최예준",
createdAt: "2024-01-15",
createdBy: MOCK_CURRENT_USER,
hasLessons: false,
@@ -30,7 +33,7 @@ export const MOCK_COURSES: Course[] = [
{
id: "2",
courseName: "React 실전 프로젝트",
instructorName: instructorNames[1] || "정시우",
instructorName: defaultInstructorNames[1] || "정시우",
createdAt: "2024-02-20",
createdBy: MOCK_CURRENT_USER,
hasLessons: false,
@@ -38,7 +41,7 @@ export const MOCK_COURSES: Course[] = [
{
id: "3",
courseName: "데이터베이스 설계",
instructorName: instructorNames[2] || "임건우",
instructorName: defaultInstructorNames[2] || "임건우",
createdAt: "2024-03-10",
createdBy: MOCK_CURRENT_USER,
hasLessons: false,
@@ -46,7 +49,7 @@ export const MOCK_COURSES: Course[] = [
{
id: "4",
courseName: "Node.js 백엔드 개발",
instructorName: instructorNames[3] || "송윤서",
instructorName: defaultInstructorNames[3] || "송윤서",
createdAt: "2024-03-25",
createdBy: MOCK_CURRENT_USER,
hasLessons: false,
@@ -54,7 +57,7 @@ export const MOCK_COURSES: Course[] = [
{
id: "5",
courseName: "TypeScript 마스터",
instructorName: instructorNames[4] || "김민수",
instructorName: defaultInstructorNames[4] || "김민수",
createdAt: "2024-04-05",
createdBy: MOCK_CURRENT_USER,
hasLessons: false,
@@ -62,7 +65,7 @@ export const MOCK_COURSES: Course[] = [
{
id: "6",
courseName: "UI/UX 디자인 기초",
instructorName: instructorNames[5] || "정대현",
instructorName: defaultInstructorNames[5] || "정대현",
createdAt: "2024-04-18",
createdBy: MOCK_CURRENT_USER,
hasLessons: false,
@@ -70,7 +73,7 @@ export const MOCK_COURSES: Course[] = [
{
id: "7",
courseName: "모바일 앱 개발",
instructorName: instructorNames[0] || "최예준",
instructorName: defaultInstructorNames[0] || "최예준",
createdAt: "2024-05-02",
createdBy: MOCK_CURRENT_USER,
hasLessons: false,
@@ -78,7 +81,7 @@ export const MOCK_COURSES: Course[] = [
{
id: "8",
courseName: "클라우드 인프라",
instructorName: instructorNames[1] || "정시우",
instructorName: defaultInstructorNames[1] || "정시우",
createdAt: "2024-05-15",
createdBy: MOCK_CURRENT_USER,
hasLessons: false,
@@ -86,7 +89,7 @@ export const MOCK_COURSES: Course[] = [
{
id: "9",
courseName: "머신러닝 입문",
instructorName: instructorNames[2] || "임건우",
instructorName: defaultInstructorNames[2] || "임건우",
createdAt: "2024-06-01",
createdBy: MOCK_CURRENT_USER,
hasLessons: false,
@@ -94,7 +97,7 @@ export const MOCK_COURSES: Course[] = [
{
id: "10",
courseName: "DevOps 실무",
instructorName: instructorNames[3] || "송윤서",
instructorName: defaultInstructorNames[3] || "송윤서",
createdAt: "2024-06-20",
createdBy: MOCK_CURRENT_USER,
hasLessons: false,