/*
 * The props of `VolunteerAccountDetailsSection`, lifted out of the component
 * file to keep it within the line budget.
 *
 * Everything here is derived rather than restated: the form bag comes from
 * `CombinedFormValues` (the type `buildVolunteerAccountInitialValues` already
 * returns), and each option list is typed as the `options` prop of the control
 * that receives it — `SelectInput` for the five dropdowns, `TagsCheckbox` for
 * the interests. Naming a field the bag does not define is now a type error
 * instead of an `undefined` at runtime.
 */
import type { FormikErrors, FormikProps, FormikTouched } from "formik";

import type {
  GroupedOption,
  Option,
} from "@/components/ui/GroupedSelectInput";
import type { SelectInputOption } from "@/components/ui/SelectInput";
import { type CombinedFormValues } from "./volunteerAccountTypes";
import type { NicknameAvailability } from "@/features/shared/nicknameAvailability";

/*
 * This form mixes both option conventions, so each list is typed for what it
 * actually carries rather than being flattened to one alias:
 *   - nationality, health concerns and occupation come from local constant
 *     tables and carry string values;
 *   - gender and relationship come from `/choices/`, whose ids are integers.
 * The old shared `any` hid the difference; keeping them apart is what made the
 * `onChange` handlers below typecheck against the right value type.
 */
/** A choice list whose value is a local constant's string key. */
export type SelectOption = SelectInputOption<string>;
/** A choice list whose value is a `/choices/` integer id. */
export type ChoiceSelectOption = SelectInputOption<number>;
/** `TagsCheckbox`'s option shape — keyed on id, not value. */
export type TagOption = { id: number; label: string };

export interface DetailsSectionProps {
  values: CombinedFormValues;
  errors: FormikErrors<CombinedFormValues>;
  touched: FormikTouched<CombinedFormValues>;
  setFieldValue: FormikProps<CombinedFormValues>["setFieldValue"];
  setFieldTouched: FormikProps<CombinedFormValues>["setFieldTouched"];
  isSocialMediaTouched: boolean;
  /** The saved nickname, so re-typing it is not treated as a conflict. */
  initialNickname?: string;
  nicknameAvailability: NicknameAvailability;
  checkNicknameAvailability: (nickname: string, currentNickname: string) => void;
  tagOptions: TagOption[];
  tagsLoading: boolean;
  nationalityOpts: SelectOption[];
  healthConcernOpts: SelectOption[];
  /* Occupation is the one grouped list: the employee trades sit under a
     heading, so this is `GroupedSelectInput`'s union, not a flat list. */
  occupationOpts: (Option | GroupedOption)[];
  relationshipOptions: ChoiceSelectOption[];
  relationshipLoading: boolean;
  genderOptions: ChoiceSelectOption[];
  genderLoading: boolean;
}
