import type { AppLocale } from "../locale";
import { DEFAULT_LOCALE } from "../locale";

// 대시보드/프로젝트 목록/전체 제출 내역 상단 GNB 및 헤더용 i18n 메시지
// - 로그인/회원가입과 동일하게 en(기본), ko 를 지원한다.

export type DashboardMessages = {
  // 메인 대시보드 헤더 제목/설명
  title: string;
  description: string;
  // 상단 GNB 탭 레이블
  navDashboard: string;
  navProjects: string;
  navSubmissions: string;
  // 헤더 오른쪽 액션 버튼/메뉴
  themeToggleLabel: string;
  menuLabel: string;
  logoutLabel: string;
  summaryTotalProjectsLabel: string;
  summaryTotalSubmissionsLabel: string;
  summaryTodaySubmissionsLabel: string;
  summaryLast7DaysSubmissionsLabel: string;
  chartTitle: string;
  chartSubtitle: string;
  chartEmptyLabel: string;
  sectionProjectsTitle: string;
  sectionProjectsEmpty: string;
  projectTotalSubmissionsPrefix: string;
  projectTotalSubmissionsSuffix: string;
  projectLatestSubmissionPrefix: string;
  projectLatestSubmissionEmpty: string;
  projectViewSubmissionsLink: string;
  projectOpenPublicPageLink: string;
  errorUnauthorized: string;
  errorGeneric: string;
  loadingText: string;
};

const DASHBOARD_MESSAGES: Record<AppLocale, DashboardMessages> = {
  en: {
    title: "Dashboard",
    description: "A quick overview of your projects and form submissions.",
    navDashboard: "Dashboard",
    navProjects: "Projects",
    navSubmissions: "All submissions",
    themeToggleLabel: "Toggle theme",
    menuLabel: "Menu",
    logoutLabel: "Log out",
    summaryTotalProjectsLabel: "Projects",
    summaryTotalSubmissionsLabel: "Total form submissions",
    summaryTodaySubmissionsLabel: "Submissions today",
    summaryLast7DaysSubmissionsLabel: "Submissions in last 7 days",
    chartTitle: "Recent submissions (daily)",
    chartSubtitle: "Only dates with recent activity are shown.",
    chartEmptyLabel: "No daily submission data yet.",
    sectionProjectsTitle: "Submissions by project",
    sectionProjectsEmpty: "No projects created yet or no submissions have been received.",
    projectTotalSubmissionsPrefix: "Total ",
    projectTotalSubmissionsSuffix: " submissions",
    projectLatestSubmissionPrefix: "Last submission:",
    projectLatestSubmissionEmpty: "No submissions yet",
    projectViewSubmissionsLink: "View form submissions",
    projectOpenPublicPageLink: "Open public page",
    errorUnauthorized: "You need to be signed in to view the dashboard. Please log in again.",
    errorGeneric: "An error occurred while loading the dashboard. Please try again later.",
    loadingText: "Loading dashboard data...",
  },
  ko: {
    title: "대시보드",
    description: "프로젝트와 폼 제출 현황을 한눈에 확인할 수 있는 요약 화면입니다.",
    navDashboard: "대시보드",
    navProjects: "프로젝트 목록",
    navSubmissions: "전체 제출 내역",
    themeToggleLabel: "테마 전환",
    menuLabel: "메뉴",
    logoutLabel: "로그아웃",
    summaryTotalProjectsLabel: "프로젝트 수",
    summaryTotalSubmissionsLabel: "전체 폼 제출 수",
    summaryTodaySubmissionsLabel: "오늘 제출 수",
    summaryLast7DaysSubmissionsLabel: "최근 7일 제출 수",
    chartTitle: "최근 제출 추이 (일별)",
    chartSubtitle: "최근 활동이 있는 날짜만 표시됩니다.",
    chartEmptyLabel: "아직 일별 제출 내역이 없습니다.",
    sectionProjectsTitle: "프로젝트별 제출 현황",
    sectionProjectsEmpty: "아직 생성된 프로젝트가 없거나 제출 내역이 없습니다.",
    projectTotalSubmissionsPrefix: "총 제출 ",
    projectTotalSubmissionsSuffix: "건",
    projectLatestSubmissionPrefix: "최근 제출:",
    projectLatestSubmissionEmpty: "제출 내역 없음",
    projectViewSubmissionsLink: "폼 제출 내역 보기",
    projectOpenPublicPageLink: "퍼블릭 페이지 열기",
    errorUnauthorized:
      "대시보드를 보려면 로그인이 필요합니다. 다시 로그인해 주세요.",
    errorGeneric:
      "대시보드 데이터를 불러오는 중 오류가 발생했습니다. 잠시 후 다시 시도해 주세요.",
    loadingText: "대시보드 데이터를 불러오는 중입니다...",
  },
};

export function getDashboardMessages(locale: AppLocale | null | undefined): DashboardMessages {
  const key = (locale ?? DEFAULT_LOCALE) as AppLocale;
  return DASHBOARD_MESSAGES[key] ?? DASHBOARD_MESSAGES[DEFAULT_LOCALE];
}
