import type { Role } from "@/types";

/**
 * System settings — pure constants and types (SPEC 35).
 *
 * This module is deliberately free of any database or server import so client
 * components can use the same shapes and labels the server does.
 *
 * Stored as key/value rows so an administrator can change institutional
 * configuration without a deployment. The OCCP year-level thresholds are
 * deliberately NOT settings — they are fixed system policy, exposed read-only
 * as `YEAR_LEVEL_POLICY`.
 */

export const STUDENT_NUMBER_NORMALIZATIONS = [
  "UPPERCASE_STRIP_SPACES_HYPHENS",
  "UPPERCASE_STRIP_SPACES",
  "UPPERCASE_TRIM",
  "NONE",
] as const;
export type StudentNumberNormalization = (typeof STUDENT_NUMBER_NORMALIZATIONS)[number];

export interface SystemSettings {
  institution_name: string;
  college_name: string;
  display_precision: number;
  student_number_normalization: StudentNumberNormalization;
  manual_override_roles: Role[];
  max_import_file_mb: number;
  encoder_can_import_students: boolean;
  archive_inactive_students: boolean;
  logo_data_url: string;
}

export const DEFAULT_SETTINGS: SystemSettings = {
  institution_name: "MMC CAST",
  college_name: "College of Medicine",
  display_precision: 2,
  student_number_normalization: "UPPERCASE_STRIP_SPACES_HYPHENS",
  manual_override_roles: ["SUPER_ADMIN", "DEAN_ADMIN"],
  max_import_file_mb: 10,
  encoder_can_import_students: true,
  archive_inactive_students: false,
  logo_data_url: "",
};

/**
 * Immutable OCCP classification policy (SPEC 4 / 35). Displayed in Settings so
 * staff can see the rule, but it is not editable through the application.
 */
export const YEAR_LEVEL_POLICY = [
  { label: "1st Year", from: 0, toExclusive: 25 },
  { label: "2nd Year", from: 25, toExclusive: 50 },
  { label: "3rd Year", from: 50, toExclusive: 75 },
  { label: "4th Year", from: 75, toInclusive: 100 },
] as const;

