/** Shapes lifted out of `ProfileVolunteerCard`. */

import { type FiltersData } from "./profileFilters";
import type { User } from "@/store/authStore";
import type {
  LearnServeOpportunityCardRecord,
  OpportunityCardRecord,
  VolunteerOpportunityCardRecord,
} from "@/features/opportunities/opportunityRecord";

/**
 * The opportunity rows these cards render: the **card/list** payload, from
 * `Website\WebsiteVolunteerOpportunityResource` and its learn & serve twin.
 *
 * Previously a local `BaseOpportunityData` union that had drifted from the
 * resource in four ways that each read as `undefined` or the wrong primitive:
 * `title_en`/`start_date`/`due_date` were `string` where the columns are
 * nullable, `registered_volunteers_count` and `from_age`/`to_age` were
 * `number` where the resource wraps them in `ar_num()` (a *string* under an
 * Arabic locale), `opportunity_images[].image` was `string` where the resource
 * emits null for an empty column, and `created_by` claimed `{ id }` — which is
 * right for a card but was being shared with detail screens where it is not.
 */
export type OpportunityData = OpportunityCardRecord;
export type VolunteerOpportunityData = VolunteerOpportunityCardRecord;
export type LearnServeOpportunityData = LearnServeOpportunityCardRecord;
export type CardType = "registered" | "organized" | "attendee" | "sponsored";

export interface ProfileVolunteerCardProps {
  buttonText?: string;
  filter_type: CardType;
  filters?: FiltersData;
  searchQuery?: string;
  /**
   * The signed-in user from `authStore`, for the creator / registration checks.
   *
   * `User | null` rather than `any`: only `id` and `user_type` are ever read off
   * it across the four card families, and both are declared on `User`. It was
   * `any` because the card types predate that interface, not because the shape
   * is unknown.
   */
  currentUser?: User | null;
  isPublicProfile?: boolean;
  user_id?: string; // Target user when viewing a public profile
  type?: CardType;
  useNewApi?: boolean; // Flag to determine which API to use
  /**
   * The redesigned individual profile: the upcoming/in-progress/finished pill
   * gives way to «حضرت / لم تحضر» and, on development cards, paid/free plus
   * provider/participant (`features/opportunities/cardStatusBadges`).
   */
  profileBadges?: "individual" | "organizer" | "sponsor";
  /** Overrides the `/list-user-opportunities/` filter_type — BE-97 B's `profile`. */
  apiFilterType?: string;
}
