교육과정 완료1
This commit is contained in:
@@ -4,70 +4,12 @@ import { useState, useEffect, useRef, useMemo } from "react";
|
||||
import AdminSidebar from "@/app/components/AdminSidebar";
|
||||
import DropdownIcon from "@/app/svgs/dropdownicon";
|
||||
import ChevronDownSvg from "@/app/svgs/chevrondownsvg";
|
||||
import { mockUsers, type UserRow } from "./mockData";
|
||||
|
||||
type TabType = 'all' | 'learner' | 'instructor' | 'admin';
|
||||
type RoleType = 'learner' | 'instructor' | 'admin';
|
||||
type AccountStatus = 'active' | 'inactive';
|
||||
|
||||
export type UserRow = {
|
||||
id: string;
|
||||
joinDate: string;
|
||||
name: string;
|
||||
email: string;
|
||||
role: RoleType;
|
||||
status: AccountStatus;
|
||||
};
|
||||
|
||||
// 랜덤 데이터 생성 함수
|
||||
function generateRandomUsers(count: number): UserRow[] {
|
||||
const surnames = ['김', '이', '박', '최', '정', '강', '조', '윤', '장', '임', '한', '오', '서', '신', '권', '황', '안', '송', '전', '홍'];
|
||||
const givenNames = ['민준', '서준', '도윤', '예준', '시우', '하준', '주원', '지호', '준서', '건우', '서연', '서윤', '지우', '서현', '민서', '하은', '예은', '윤서', '채원', '지원'];
|
||||
const roles: RoleType[] = ['learner', 'instructor', 'admin'];
|
||||
const statuses: AccountStatus[] = ['active', 'inactive'];
|
||||
|
||||
const users: UserRow[] = [];
|
||||
const startDate = new Date('2024-01-01');
|
||||
const endDate = new Date('2025-03-01');
|
||||
|
||||
for (let i = 1; i <= count; i++) {
|
||||
const surname = surnames[Math.floor(Math.random() * surnames.length)];
|
||||
const givenName = givenNames[Math.floor(Math.random() * givenNames.length)];
|
||||
const name = `${surname}${givenName}`;
|
||||
const email = `user${i}@example.com`;
|
||||
|
||||
// 랜덤 날짜 생성
|
||||
const randomTime = startDate.getTime() + Math.random() * (endDate.getTime() - startDate.getTime());
|
||||
const randomDate = new Date(randomTime);
|
||||
const joinDate = randomDate.toISOString().split('T')[0];
|
||||
|
||||
const role = roles[Math.floor(Math.random() * roles.length)];
|
||||
const status = statuses[Math.floor(Math.random() * statuses.length)];
|
||||
|
||||
users.push({
|
||||
id: String(i),
|
||||
joinDate,
|
||||
name,
|
||||
email,
|
||||
role,
|
||||
status,
|
||||
});
|
||||
}
|
||||
|
||||
return users;
|
||||
}
|
||||
|
||||
const mockUsers: UserRow[] = generateRandomUsers(111);
|
||||
|
||||
// 강사 목록 가져오기 함수 export
|
||||
// TODO: 나중에 DB에서 가져오도록 변경 예정
|
||||
// 예: export async function getInstructors(): Promise<UserRow[]> {
|
||||
// const response = await fetch('/api/instructors');
|
||||
// return response.json();
|
||||
// }
|
||||
export function getInstructors(): UserRow[] {
|
||||
// 현재는 mock 데이터 사용, 나중에 DB에서 가져오도록 변경
|
||||
return mockUsers.filter(user => user.role === 'instructor' && user.status === 'active');
|
||||
}
|
||||
|
||||
const roleLabels: Record<RoleType, string> = {
|
||||
learner: '학습자',
|
||||
|
||||
Reference in New Issue
Block a user