/**
 * The volunteer-opportunity roles, teams and volunteer-picker payloads.
 *
 * Three small resources that are easy to confuse with their neighbours:
 *
 * - **Roles and teams key the parent as `opportunity_id`.** The learn & serve
 *   time slot resource calls the same thing **`opportunity`** (a bare integer
 *   under a singular name). Mixing them up reads `undefined`.
 * - **`VolunteerPickerResource` emits no `is_public`.** Every other
 *   profile-bearing payload does, and the private-vs-public profile route is
 *   chosen from it — so the three tables built on the picker send everyone
 *   through the private profile path and rely on the server's redirect. That
 *   is recorded in `profilePath()` and is a backend gap, not a frontend one.
 */

import type { MasterChoiceDisplay } from "@/features/shared/apiPrimitives";

/** `Opportunity\VolunteerOpportunityRoleResource`. */
export interface VolunteerOpportunityRoleRecord {
  id: number;
  /** Note the name: `opportunity_id`, not `opportunity`. */
  opportunity_id: number;
  role_name_en: string | null;
  role_name_ar: string | null;
  instructions_en: string | null;
  instructions_ar: string | null;
  participants_needed: number | null;
  /** Seat availability, so a full role can be disabled rather than rejected. */
  assigned_count: number;
  remaining_slots: number;
  is_full: boolean;
}

/** `Opportunity\VolunteerOpportunityTeamResource`. Four keys, no more. */
export interface VolunteerOpportunityTeamRecord {
  id: number;
  opportunity_id: number;
  team_name_en: string | null;
  team_name_ar: string | null;
}

/**
 * `Volunteer\VolunteerPickerResource` — `GET /all-volunteers/` and
 * `/available-volunteers/`.
 *
 * `id` is the **volunteer profile** id and `user_id` the user's; the nested
 * `user` block repeats `full_name`, `profile_pic` and `nickname` from the same
 * two sources, so the two never disagree. The `*_last4` fields are the only
 * identity fragments exposed — never a whole civil id or passport number.
 */
export interface VolunteerPickerRecord {
  /** `volunteer_profiles.id`. */
  id: number;
  user_id: number;
  nickname: string | null;
  /** `fullName()` — `''` rather than null when there is no name. */
  full_name: string;
  profile_pic: string | null;
  gender_display: MasterChoiceDisplay | null;
  is_verified: boolean;
  /** Last four digits only. Null when the column is empty. */
  civil_id_last4: string | null;
  passport_last4: string | null;
  phone_last4: string | null;
  /** Null when the profile has no user row. */
  user: {
    id: number;
    full_name: string;
    profile_pic: string | null;
    nickname: string | null;
  } | null;
}
