// Each term carries both the spec keys (title/description/is_active/
// starts_at/ends_at/cover_url/created_at — camelized) and the UI-only
// keys the current frontend reads (image, startDate, endDate,
// studentsCount, coursesCount). See docs/backend-api-todo.md.
const makeTerm = (overrides) => {
  const startsAt = overrides.startsAt ?? overrides.startDate ?? ''
  const endsAt = overrides.endsAt ?? overrides.endDate ?? ''
  const coverUrl = overrides.coverUrl ?? overrides.image ?? ''
  return {
    // --- spec ---
    id: overrides.id,
    title: overrides.title ?? '',
    description: overrides.description ?? '',
    isActive: overrides.isActive ?? true,
    startsAt,
    endsAt,
    coverUrl,
    createdAt: overrides.createdAt ?? '',

    // --- ui-only ---
    image: coverUrl,
    startDate: startsAt,
    endDate: endsAt,
    studentsCount: overrides.studentsCount ?? 0,
    coursesCount: overrides.coursesCount ?? 0,
  }
}

export const adminTerms = [
  makeTerm({
    id: 1,
    title: 'ترم پاییز ۱۴۰۴',
    description: 'ترم پاییز با محوریت آموزش معارف اسلامی.',
    coverUrl: 'https://picsum.photos/seed/term1/200/200',
    startsAt: '2025-09-23T00:00:00.000Z',
    endsAt: '2026-01-20T00:00:00.000Z',
    isActive: true,
    studentsCount: 18,
    coursesCount: 4,
    createdAt: '2025-08-01T08:00:00.000Z',
  }),
  makeTerm({
    id: 2,
    title: 'ترم زمستان ۱۴۰۴',
    description: 'ترم زمستان با تمرکز بر فقه و اصول.',
    coverUrl: 'https://picsum.photos/seed/term2/200/200',
    startsAt: '2026-01-21T00:00:00.000Z',
    endsAt: '2026-04-20T00:00:00.000Z',
    isActive: true,
    studentsCount: 12,
    coursesCount: 3,
    createdAt: '2025-11-10T08:00:00.000Z',
  }),
  makeTerm({
    id: 3,
    title: 'ترم بهار ۱۴۰۵',
    description: 'ترم بهار ویژه دوره‌های تخصصی.',
    coverUrl: '',
    startsAt: '2026-04-21T00:00:00.000Z',
    endsAt: '2026-08-21T00:00:00.000Z',
    isActive: false,
    studentsCount: 0,
    coursesCount: 2,
    createdAt: '2026-02-15T08:00:00.000Z',
  }),
]

export { makeTerm }

export const termStudentLinks = new Map([
  [
    1,
    [
      { userId: 100, isOnLeave: false },
      { userId: 101, isOnLeave: false },
      { userId: 102, isOnLeave: true },
      { userId: 103, isOnLeave: false },
    ],
  ],
  [
    2,
    [
      { userId: 104, isOnLeave: false },
      { userId: 105, isOnLeave: false },
    ],
  ],
])
