import { dt } from "@/lib/dt"
import { getBookingConfirmation } from "@/lib/trpc/memoizedRequests"

import { CreditCardAddIcon } from "@/components/Icons"
import Button from "@/components/TempDesignSystem/Button"
import Body from "@/components/TempDesignSystem/Text/Body"
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
import { getIntl } from "@/i18n"
import { getLang } from "@/i18n/serverContext"

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

import type { BookingConfirmationProps } from "@/types/components/hotelReservation/bookingConfirmation/bookingConfirmation"

export default async function PaymentDetails({
  confirmationNumber,
}: BookingConfirmationProps) {
  const intl = await getIntl()
  const lang = getLang()
  const { booking } = await getBookingConfirmation(confirmationNumber)
  return (
    <div className={styles.details}>
      <Subtitle color="uiTextHighContrast" type="two">
        {intl.formatMessage({ id: "Payment details" })}
      </Subtitle>
      <div className={styles.payment}>
        <Body color="uiTextHighContrast">
          {intl.formatNumber(booking.totalPrice, {
            currency: booking.currencyCode,
            style: "currency",
          })}{" "}
          {intl.formatMessage({ id: "has been paid" })}
        </Body>
        <Body color="uiTextHighContrast">
          {dt(booking.createDateTime)
            .locale(lang)
            .format("ddd D MMM YYYY, hh:mm")}
        </Body>
        <Body color="uiTextHighContrast">
          {intl.formatMessage(
            { id: "{card} ending with {cardno}" },
            { card: "N/A", cardno: "N/A" }
          )}
        </Body>
      </div>
      <Button
        className={styles.btn}
        intent="text"
        size="small"
        theme="base"
        variant="icon"
        wrapping
      >
        <CreditCardAddIcon />
        {intl.formatMessage({ id: "Save card to profile" })}
      </Button>
    </div>
  )
}
