import type { Role } from "@/shared/types/permissions"

/**
 * Profile 概览类型
 *
 * 通过配置驱动角色 → 概览区块的映射，新增角色只需在此添加条目。
 * 避免在页面层使用 roles.includes("xxx") 硬编码。
 */
export type ProfileOverviewType = "student" | "teacher" | "none"

const PROFILE_OVERVIEW_MAP: Partial<Record<Role, ProfileOverviewType>> = {
  student: "student",
  teacher: "teacher",
}

/**
 * 根据角色列表解析首选概览类型。
 * 优先级：student > teacher > none
 */
export function resolveProfileOverviewType(roles: Role[]): ProfileOverviewType {
  for (const role of roles) {
    const overviewType = PROFILE_OVERVIEW_MAP[role]
    if (overviewType) return overviewType
  }
  return "none"
}
