"use client"

import { useState } from "react"
import { Button as ButtonRAC } from "react-aria-components"
import { useIntl } from "react-intl"

import { Button } from "@scandic-hotels/design-system/Button"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import Modal from "@scandic-hotels/design-system/Modal"
import { Typography } from "@scandic-hotels/design-system/Typography"

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

export function GuaranteeInfoModal() {
  const [isOpen, setIsOpen] = useState(false)
  const intl = useIntl()

  return (
    <>
      <ButtonRAC
        type="button"
        className={styles.infoButton}
        onPress={() => setIsOpen(true)}
      >
        <MaterialIcon icon="info" size={20} color="CurrentColor" />
      </ButtonRAC>
      <Modal
        title={intl.formatMessage({
          id: "myStay.guaranteeInfoModal.heading",
          defaultMessage: "Your booking is guaranteed",
        })}
        isOpen={isOpen}
        onToggle={setIsOpen}
      >
        <div className={styles.content}>
          <Typography variant="Body/Lead text">
            <p>
              {intl.formatMessage({
                id: "myStay.guaranteeInfo.description",
                defaultMessage:
                  "The hotel will hold your booking, even if you arrive after 18:00. In case of a no-show, you will be charged for the first night.",
              })}
            </p>
          </Typography>
          <Typography
            variant="Body/Paragraph/mdRegular"
            className={styles.textSecondary}
          >
            <p>
              {intl.formatMessage({
                id: "myStay.guaranteeInfoModal.ancillariesInfo",
                defaultMessage:
                  "If you added extras, they'll be charged in case of a no-show, unless cancelled by 23:59 the night before.",
              })}
            </p>
          </Typography>

          <Button
            className={styles.closeButton}
            variant="Secondary"
            color="Primary"
            size="Medium"
            typography="Body/Paragraph/mdBold"
            onPress={() => setIsOpen(false)}
          >
            {intl.formatMessage({
              id: "common.close",
              defaultMessage: "Close",
            })}
          </Button>
        </div>
      </Modal>
    </>
  )
}
