/**
 * The opportunity list filters: their shape, and what "no filters" means.
 *
 * Both were duplicated. The type lived inside `AllOpportuniteFilterModal` — a
 * *component* — and was imported from there by four other files, and
 * `VolunteerCard` had declared its own structurally-identical copy that nothing
 * kept in step. The empty object was written out in full in four places, so
 * adding a filter meant remembering all four or leaving one list unable to
 * clear it.
 */

export interface AllOpportunitiesFiltersData {
  startDate: string;
  endDate: string;
  tags: string[];
  location: string;
  gender: string;
  age: [number | null, number | null];
  opportunity_nationality: string;
  type: string;
  isRelief: boolean;
  isUrgent: boolean;
  isSpecialNeed: boolean;
  isInPerson: boolean;
  isOnline: boolean;
  matchMyInterest: boolean;
  status: string;
  sortBy: string;
}

/**
 * Every filter cleared.
 *
 * `age` is a fresh tuple per read rather than a shared one, so a list that
 * mutates its own copy cannot clear another list's.
 */
export const EMPTY_OPPORTUNITY_FILTERS: () => AllOpportunitiesFiltersData =
  () => ({
    startDate: "",
    endDate: "",
    tags: [],
    location: "",
    gender: "",
    age: [null, null],
    opportunity_nationality: "",
    type: "",
    isRelief: false,
    isUrgent: false,
    isSpecialNeed: false,
    isInPerson: false,
    isOnline: false,
    matchMyInterest: false,
    status: "",
    sortBy: "",
  });
