/**
 * 各角色仪表盘 Widget 布局配置。
 *
 * 通过配置驱动决定每个角色渲染哪些 Widget 及其布局位置。
 * 新增角色或调整 Widget 只需修改此配置文件，不需动组件代码。
 */

import type { DashboardLayoutConfig } from "@/modules/dashboard/types"

/** 管理员仪表盘 Widget 配置 */
export const ADMIN_WIDGET_CONFIG: DashboardLayoutConfig = {
  role: "admin",
  widgets: [
    { id: "admin-stats-bar", slot: "stats", skeletonVariant: "stats", layoutClassName: "grid gap-4 md:grid-cols-2 lg:grid-cols-4", defaultVisible: true },
    { id: "admin-quick-actions", slot: "actions", skeletonVariant: "card", layoutClassName: "grid gap-4 md:grid-cols-2 lg:grid-cols-3", defaultVisible: true },
    { id: "admin-trend-charts", slot: "charts", skeletonVariant: "chart", layoutClassName: "grid gap-6 lg:grid-cols-2", defaultVisible: true },
    { id: "admin-user-roles", slot: "cards-left", skeletonVariant: "card", layoutClassName: "lg:col-span-1", defaultVisible: true },
    { id: "admin-content", slot: "cards-center", skeletonVariant: "card", layoutClassName: "lg:col-span-1", defaultVisible: true },
    { id: "admin-homework-activity", slot: "cards-right", skeletonVariant: "card", layoutClassName: "lg:col-span-1", defaultVisible: true },
    { id: "admin-recent-users", slot: "table", skeletonVariant: "table", layoutClassName: "", defaultVisible: true },
  ],
}

/** 教师仪表盘 Widget 配置 */
export const TEACHER_WIDGET_CONFIG: DashboardLayoutConfig = {
  role: "teacher",
  widgets: [
    { id: "teacher-stats", slot: "stats", skeletonVariant: "stats", layoutClassName: "grid gap-4 md:grid-cols-2 lg:grid-cols-4", defaultVisible: true },
    { id: "teacher-todo", slot: "main-top", skeletonVariant: "card", layoutClassName: "lg:col-span-8", defaultVisible: true },
    { id: "teacher-schedule", slot: "sidebar-top", skeletonVariant: "card", layoutClassName: "lg:col-span-4", defaultVisible: true },
    { id: "teacher-grade-trends", slot: "main-middle", skeletonVariant: "chart", layoutClassName: "lg:col-span-8", defaultVisible: true },
    { id: "teacher-recent-submissions", slot: "main-bottom", skeletonVariant: "list", layoutClassName: "lg:col-span-8", defaultVisible: true },
    { id: "teacher-homework", slot: "sidebar-middle", skeletonVariant: "list", layoutClassName: "lg:col-span-4", defaultVisible: true },
    { id: "teacher-classes", slot: "sidebar-bottom", skeletonVariant: "list", layoutClassName: "lg:col-span-4", defaultVisible: true },
  ],
}

/** 学生仪表盘 Widget 配置 */
export const STUDENT_WIDGET_CONFIG: DashboardLayoutConfig = {
  role: "student",
  widgets: [
    { id: "student-stats", slot: "stats", skeletonVariant: "stats", layoutClassName: "grid gap-4 md:grid-cols-2 lg:grid-cols-4", defaultVisible: true },
    { id: "student-upcoming-assignments", slot: "main-top", skeletonVariant: "list", layoutClassName: "lg:col-span-2", defaultVisible: true },
    { id: "student-grades", slot: "main-bottom", skeletonVariant: "card", layoutClassName: "lg:col-span-2", defaultVisible: true },
    { id: "student-today-schedule", slot: "sidebar", skeletonVariant: "card", layoutClassName: "", defaultVisible: true },
  ],
}

/** 家长仪表盘 Widget 配置 */
export const PARENT_WIDGET_CONFIG: DashboardLayoutConfig = {
  role: "parent",
  widgets: [
    { id: "parent-attention-banner", slot: "banner", skeletonVariant: "card", layoutClassName: "", defaultVisible: true },
    { id: "parent-quick-entries", slot: "actions", skeletonVariant: "card", layoutClassName: "grid grid-cols-2 gap-3 sm:grid-cols-4", defaultVisible: true },
    { id: "parent-children-cards", slot: "main", skeletonVariant: "list", layoutClassName: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4", defaultVisible: true },
  ],
}

/** 按角色获取 Widget 配置 */
export function getWidgetConfig(role: DashboardLayoutConfig["role"]): DashboardLayoutConfig {
  switch (role) {
    case "admin": return ADMIN_WIDGET_CONFIG
    case "teacher": return TEACHER_WIDGET_CONFIG
    case "student": return STUDENT_WIDGET_CONFIG
    case "parent": return PARENT_WIDGET_CONFIG
  }
}
