import type { RegistrationRow } from "@/features/opportunities/registrationRow";

/**
 * The shapes the development-opportunity registrations screen works in.
 *
 * `LearnServeRegisterListState` is the payload the detail page stashes before
 * navigating here (see `lib/navigationState.ts`), so it is a contract between
 * two screens and belongs where both can import it.
 */

export interface LearnServeRegisterListState {
  id?: string;
  start_at?: string | null;
  end_at?: string | null;
  time_slots?: { date?: string | null; start_time?: string | null; end_time?: string | null }[] | null;
  start_date?: string;
  end_date?: string;
  start_time?: string;
  end_time?: string;
  registration_closes_at?: string | null;
  // Check-in fields forwarded from the detail screen; see `lib/checkInWindow.ts`.
  requires_check_in?: boolean;
  manual_attendance_enabled?: boolean;
  preparation_valid_until?: string | null;
  preparation_valid_until_at?: string | null;
  is_preparation_window_closed?: boolean;
  preparation_reopened_until?: string | null;
  /** The final-day scan start; manual attendance opens at the same instant. */
  scan_opens_at?: string | null;
  /** BE-102 — the button reads all three; the screen fetched none of them. */
  opportunity_status?: string | null;
  learning_type_display?: { value_en?: string | null; value_ar?: string | null } | null;
  certificate_type_display?: { value_en?: string | null; value_ar?: string | null } | null;
  /** BE-125 — a free opportunity has no payments table to open. */
  is_paid?: boolean | null;
}

/**
 * One registration row, as either registration endpoint sends it.
 *
 * `RegistrationRow` — the "either shape" type the shared
 * `registrationPerson()` adapter reads — rather than a nested
 * `user: { profile_pic, full_name, civil_id, … }` object.
 * `LearnServeOpportunityRegistrationResource` sends all of those **flat** and
 * has no nested `user` at all; `VolunteerOpportunityRegistrationResource` does
 * nest one, but it holds only `id` plus the four emergency-contact fields.
 * Declaring the nested shape as the only shape is what made the cells read
 * `undefined` before BE-16 was worked around with the adapter.
 *
 * Read a row through `registrationPerson()` rather than reaching into it.
 */
export type RegisteredUser = RegistrationRow;
