import { Lang } from "@/constants/languages"
import { membershipLevels } from "@/constants/membershipLevels"
import {
  Block,
  CardsGrid,
  DynamicContent,
  RteBlockContent,
} from "@/server/routers/contentstack/loyaltyPage/output"

import type { IntlFormatters } from "@formatjs/intl"

import { User } from "@/types/user"

export type BlocksProps = {
  blocks: Block[]
}

export type DynamicContentProps = {
  dynamicContent: DynamicContent["dynamic_content"]
  firstItem: boolean
}

export type DynamicComponentProps = {
  component: DynamicContent["dynamic_content"]["component"]
}

export type CardsGridProps = Pick<CardsGrid, "cards_grid">

export type Content = { content: RteBlockContent["content"]["content"] }

type Benefit = { title: string; description: string }

type OverviewTableTitleTranslation = {
  text: string
  highlight: boolean
}

export type OverviewTableTitleProps = { texts: OverviewTableTitleTranslation[] }

export type OverviewTableProps = { user: User | null }

export type Level = {
  level: membershipLevels
  name: string
  requiredPoints: number
  requiredNights?: number
  icon: string
  benefits: Benefit[]
}

export type LevelCardProps = {
  formatMessage: IntlFormatters["formatMessage"]
  lang: Lang
  level: Level
}

export type ComparisonLevel = {
  tier: membershipLevels
  name: string
  description: string
  requirement: string
  icon: string
  benefits: [
    {
      name: string
      description: string
      unlocked: boolean
      value?: string
      valueDetails?: string
    },
  ]
}

export type LevelSummaryProps = {
  level: ComparisonLevel
}

export type BenefitCardProps = {
  comparedValues: BenefitValueInformation[]
  title: string
  description: string
}

type BenefitValueInformation = {
  unlocked: boolean
  value?: string
  valueDetails?: string
}

export type BenefitValueProps = {
  benefit: BenefitValueInformation
}

export type BenefitListProps = {
  levels: ComparisonLevel[]
}

export type LargeTableProps = {
  levels: ComparisonLevel[]
}

export type BenefitTableHeaderProps = {
  name: string
  description: string
}

export enum overviewTableActionsEnum {
  SET_SELECTED_LEVEL_A_MOBILE = "SET_SELECTED_LEVEL_A_MOBILE",
  SET_SELECTED_LEVEL_B_MOBILE = "SET_SELECTED_LEVEL_B_MOBILE",
  SET_SELECTED_LEVEL_A_DESKTOP = "SET_SELECTED_LEVEL_A_DESKTOP",
  SET_SELECTED_LEVEL_B_DESKTOP = "SET_SELECTED_LEVEL_B_DESKTOP",
  SET_SELECTED_LEVEL_C_DESKTOP = "SET_SELECTED_LEVEL_C_DESKTOP",
}

export type OverviewTableReducerAction = {
  type: overviewTableActionsEnum
  payload: ComparisonLevel
}
