/**
 * Users domain. Pure types: no framework, no infrastructure.
 */

export interface Profile {
  userId: string;
  displayName: string | null;
  phone: string | null;
  preferences: UserPreferences;
  createdAt: Date;
  updatedAt: Date;
}

/** Preferencias gestionadas por el cliente desde su cuenta. */
export interface UserPreferences {
  /** Aviso por email de cambios de estado de pedidos. */
  orderUpdates: boolean;
  /** Boletín de novedades. */
  newsletter: boolean;
  /** Ofertas y promociones. */
  promos: boolean;
}

export const DEFAULT_PREFERENCES: UserPreferences = {
  orderUpdates: true,
  newsletter: false,
  promos: false,
};

/** Fields a profile update may set. Undefined = leave unchanged. */
export interface ProfilePatch {
  displayName?: string | null;
  phone?: string | null;
  preferences?: Partial<UserPreferences>;
}

/** Joined identity_users + users_profiles row for admin customer listing. */
export interface CustomerSummary {
  userId: string;
  email: string;
  role: string;
  displayName: string | null;
  phone: string | null;
  createdAt: Date;
}

/** Paginated customer list result. */
export interface CustomerListResult {
  items: CustomerSummary[];
  total: number;
}

/** Filters for customer listing. */
export interface CustomerListOptions {
  q?: string;
  offset: number;
  limit: number;
}
