import type { BaseEntity } from "../common";

export interface IDropdownOptionMeta {
  icon?: string;
  color?: string;
  badge?: string;
}

export interface IDropdownOption extends BaseEntity {
  settingId: string;
  /** Stored value (machine-readable identifier). */
  value: string;
  /** Display label shown to end users. */
  label: string;
  /** Optional helper text. */
  note?: string | null;
  disabled: boolean;
  order: number;
  meta?: IDropdownOptionMeta | null;
}

export interface IDropdownSettingMeta {
  icon?: string;
  color?: string;
  searchable?: boolean;
  clearable?: boolean;
  permissions?: string[];
  version?: string;
}

export interface IDropdownSetting extends BaseEntity {
  /** Stable code referenced from forms (snake_case). */
  code: string;
  /** Display label for admins. */
  label: string;
  description?: string | null;
  multiple: boolean;
  meta?: IDropdownSettingMeta | null;
  /**
   * Options that belong to this dropdown. Named `children` to match the shape
   * historically consumed by the freight portal.
   */
  children: IDropdownOption[];
}

/* ------------------------------------------------------------------ *
 *  Wire DTOs (shared between API and frontend)
 * ------------------------------------------------------------------ */

export interface CreateDropdownOptionDto {
  value: string;
  label: string;
  note?: string;
  disabled?: boolean;
  order?: number;
  meta?: IDropdownOptionMeta;
}

export type UpdateDropdownOptionDto = Partial<CreateDropdownOptionDto>;

export interface CreateDropdownSettingDto {
  code: string;
  label: string;
  description?: string;
  multiple?: boolean;
  meta?: IDropdownSettingMeta;
  children?: CreateDropdownOptionDto[];
}

export type UpdateDropdownSettingDto = Partial<
  Omit<CreateDropdownSettingDto, "children">
>;
