export interface CoreMember {
  member_id: string;
  member_number: string;
  membership_number: string;
  is_active: boolean;
  is_deleted: boolean;
  created_at: string;
  updated_at: string | null;
  user_id: string;
  email: string;
  first_name: string;
  last_name: string;
  is_family: boolean;
  is_owner: boolean;
  /** Viewpoint's primary-contact flag; absent on member-DB-only payloads. */
  is_primary?: boolean;
  user_is_active: boolean;
  user_is_deleted: boolean;
  account_type_id: string;
  account_type_name: string;
  account_type_ext_id: string;
  account_type_is_active: boolean;
  account_status_id: string;
  account_status_name: string;
  account_status_ext_id: string;
  account_status_is_active: boolean;
  // Member profile id, used as the Viewpoint profile-sync target.
  id: string;
}

export interface CoreMembership extends CoreMember {
  totalMembers: number;
}

export interface CoreMemberAccountType {
  id: string;
  name: string;
  is_active: boolean;
  ext_id: string;
  policy_id: string;
  policy_name: string;
  has_login: string;
  has_curated_event_booking: string;
  has_destination_booking: string;
  created_at: string;
  updated_at: string | null;
}

export interface CoreMemberDetailed extends CoreMember {
  address_line_one: string;
  address_line_two?: string;
  city: string;
  country: string;
  postcode: string;
  mobile: string;
  nationality: string;
  state: string;
  date_of_birth: string;
  avatar?: string;
  date_of_anniversary?: string;
  personal_interests?: string;
  preference_id?: string;
  crmData?: VpAccountCrmData[];
}

export interface VpAccountCrmData {
  DataID: number;
  FieldID: number;
  Value: number;
  FieldName: string;
  ValueName: string;
}

export interface VpAccountDetails {
  AccountID: string;
  AccountName: string;
  AccountType: string;
  AccountTypeID: number;
  ServiceCenter: string;
  ServiceCenterID: number;
  AccountStatus: string;
  AccountStatusID: number;
  DefaultChargeCenter: number;
  JoinedDate: string;
  BillingAddressLine1: string;
  BillingAddressLine2: string;
  BillingAddressState: string;
  BillingAddressCity: string;
  BillingAddrCountry: string;
  BillingPostcode: string | null;
  Notes?: string;
  CRMData?: VpAccountCrmData[];
}

export interface VpContactDetails {
  AccountID: string;
  ContactID: number;
  Title: string | null;
  TitleID: number;
  FirstName: string;
  LastName: string;
  MailName: string;
  Salutation: string | null;
  Email: string;
  Phone: string | null;
  Fax: string | null;
  Mobile: string | null;
  AddressLine1: string | null;
  AddressLine2: string | null;
  AddressState: string | null;
  AddressCity: string | null;
  AddrCountry: string | null;
  Postcode: string | null;
  Nationality: string | null;
  DateOfBirth: string;
  IsPrimary: boolean;
  IsOwner: boolean;
  IsFamily: boolean;
  IsAuthority: boolean;
  Active: boolean;
  Deleted: boolean;
  CreateDate: string | null;
  ModifyDate: string;
  CRMData: VpAccountCrmData[];
}

export interface CoreMemberSession {
  id: string;
  application_type?: string;
  application_version: string;
  browser?: string;
  created_at: string;
  device_type?: string;
  ip_address?: string;
  location?: string;
  os?: string;
}

export interface CoreMemberSavedSearch {
  id: string;
  label: string;
  search_term: string | null;
  parameters: Record<string, unknown> | null;
  source: string;
  frequency: number | null;
  last_used: string | null;
  created_at: string;
  updated_at: string | null;
}

export interface CoreMemberActivityLog {
  id: string;
  action: string;
  entity_type: string;
  entity_id: string;
  before_state: Record<string, unknown> | null;
  after_state: Record<string, unknown> | null;
  delta: Record<string, unknown> | null;
  status: string;
  error_message: string | null;
  ip_address: string | null;
  user_agent: string | null;
  metadata: Record<string, unknown> | null;
  created_at: string;
  actor_id: string;
  actor_type: "console_user" | "member";
  userDetails: {
    name: string | null;
    first_name: string | null;
    last_name: string | null;
  };
}
