"use client"

import Cheques from "./Cheques"
import Points from "./Points"
import Price from "./Price"
import Vouchers from "./Vouchers"

import { PriceTypeEnum } from "@/types/components/hotelReservation/myStay/myStay"
import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation"

interface PriceTypeProps
  extends Pick<
    BookingConfirmation["booking"],
    | "cheques"
    | "currencyCode"
    | "rateDefinition"
    | "totalPoints"
    | "totalPrice"
    | "vouchers"
  > {
  formattedTotalPrice: string
  isCancelled: boolean
  priceType: PriceTypeEnum
}

export default function PriceType({
  cheques,
  formattedTotalPrice,
  isCancelled,
  currencyCode,
  priceType,
  rateDefinition,
  totalPoints,
  totalPrice,
  vouchers,
}: PriceTypeProps) {
  switch (priceType) {
    case PriceTypeEnum.cheque:
      return (
        <Cheques
          cheques={cheques}
          currencyCode={currencyCode}
          isCancelled={isCancelled}
          price={totalPrice}
        />
      )
    case PriceTypeEnum.money:
      return (
        <Price
          isCancelled={isCancelled}
          isMember={rateDefinition.isMemberRate}
          price={formattedTotalPrice}
        />
      )
    case PriceTypeEnum.points:
      return (
        <Points
          isCancelled={isCancelled}
          points={totalPoints}
          price={totalPrice}
          currencyCode={currencyCode}
        />
      )
    case PriceTypeEnum.voucher:
      return (
        <Vouchers
          currencyCode={currencyCode}
          isCancelled={isCancelled}
          price={totalPrice}
          vouchers={vouchers}
        />
      )
    default:
      return null
  }
}
