import { useIntl } from "react-intl"

import Button from "@/components/TempDesignSystem/Button"
import Body from "@/components/TempDesignSystem/Text/Body"
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"

import styles from "./rateSummary.module.css"

import { RateSummaryProps } from "@/types/components/hotelReservation/selectRate/rateSummary"

export default function RateSummary({
  rateSummary,
  isUserLoggedIn,
}: RateSummaryProps) {
  const intl = useIntl()

  const priceToShow = isUserLoggedIn ? rateSummary.member : rateSummary.public

  return (
    <div className={styles.summary}>
      <div className={styles.summaryText}>
        <Subtitle color="uiTextHighContrast">{rateSummary.roomType}</Subtitle>
        <Body color="uiTextMediumContrast">{rateSummary.priceName}</Body>
      </div>
      <div className={styles.summaryPrice}>
        <div className={styles.summaryPriceText}>
          <>
            <Subtitle color={isUserLoggedIn ? "red" : "uiTextHighContrast"}>
              {priceToShow?.localPrice.pricePerStay}{" "}
              {priceToShow?.localPrice.currency}
            </Subtitle>
            <Body color="uiTextMediumContrast">
              {intl.formatMessage({ id: "Approx." })}{" "}
              {priceToShow?.requestedPrice?.pricePerStay}{" "}
              {priceToShow?.requestedPrice?.currency}
            </Body>
          </>
        </div>
        <Button type="submit" theme="base">
          {intl.formatMessage({ id: "Continue" })}
        </Button>
      </div>
    </div>
  )
}
