import { ApiResponse } from './api-response.interface';

export type CartEditingPolicyCode = 'disabled' | 'quantity_and_remove' | 'full';

export interface CartEditingPolicy {
  code: CartEditingPolicyCode;
  allow_modify: boolean;
  allow_delete: boolean;
  allow_update_quantity: boolean;
  allow_update_variant: boolean;
}

export interface BankAccount {
  id: number;
  tenant_code: string;
  titular: string;
  entidad: string;
  alias: string;
  cvu: string;
}

export interface WebsiteType {
  codigo: string;
  nombre: string;
  primary_color: string | null;
  secondary_color: string | null;
  danger_color: string | null;
  success_color: string | null;
  site_logo: string | null;
}

export interface HeroConfig {
  background_image_id?: string | ResponsiveImage | null;
  title_html?: string | null;
  description_html?: string | null;
  button_text?: string | null;
  button_href?: string | null;
}

export interface ResponsiveImage {
  desktop: string;
  mobile: string;
}

export interface AdditionalInfoConfig {
  description?: string | null;
}

export interface EventDate {
  id?: number;
  date: string;
  start_time: string;
  end_time: string;
}

export interface EventConfig {
  id?: number;
  title?: string | null;
  location?: string | null;
  dates_text?: string | null;
  dates?: EventDate[] | null;
  contact?: SocialMedia[];
}

export interface ActiveEventDate {
  id: number;
  date: string;
  time_start: string;
  time_end: string;
}

export interface TenantEvent {
  title: string;
  location: string;
  dates: ActiveEventDate[];
}

export interface WebsiteExtras {
  carousel?: string[];
  heroConfig?: HeroConfig | null;
  additionalInfoConfig?: AdditionalInfoConfig | null;
  [extraName: string]: unknown;
}

export interface Menu {
  id: number;
  code: string;
  label: string;
  parent_menu_code: string | null;
  content_type: 'static' | 'dynamic';
  route: string;
  static_content?: unknown;
  submenues: Menu[];
}

export interface SocialMedia {
  code: string;
  icon: string;
  name: string;
  url: string;
}

export interface Category {
  id: number;
  nombre: string;
  subcategories: Category[];
}

export interface Tenant {
  id: number;
  codigo: string;
  nombre: string;
  dominio: string;
  base_path?: string;
  site_title?: string | null;
  address?: string | null;
  phone?: string | null;
  favicon?: string | null;
  primary_color: string;
  secondary_color: string;
  danger_color: string;
  success_color: string;
  header_bg_color: string;
  footer_bg_color: string;
  header_logo: string;
  footer_logo: string;
  header_bg_image?: string | null;
  footer_bg_image?: string | null;
  website_type_code?: string | null;
  website_type?: WebsiteType | null;
  event_date_text?: string | null;
  extras?: WebsiteExtras;
  event?: TenantEvent | null;
  selected_bank_account_id?: number | null;
  selected_bank_account?: BankAccount | null;
  search_product_layout?: 'row' | 'column_with_image' | 'column_with_cart' | 'ticket_selector';
  search_group_layout?: 'paginated' | 'simple' | 'simple_vertical' | 'carousel' | 'single';
  search_items_per_page?: number;
  display_categories?: boolean;
  display_seach_bar?: boolean;
  display_cart?: boolean;
  cart_editing_policy?: CartEditingPolicy;
  checkout_editing_policy?: CartEditingPolicy;
  display_cart_item_images?: boolean;
  social_media?: SocialMedia[];
  menues?: Menu[];
  categories: Category[];
}

export type TenantBootstrapResponse = ApiResponse<Tenant>;
