import { useIntl } from "react-intl"

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

import Card from "./Card"

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

import type { InitialProps } from "@/types/components/blocks/surprises"

export default function Initial({ totalSurprises, onOpen }: InitialProps) {
  const intl = useIntl()

  return (
    <Card
      title={intl.formatMessage({
        id: "rewards.surprise",
        defaultMessage: "Surprise!",
      })}
    >
      <Typography variant="Body/Paragraph/mdRegular">
        <p className={styles.textCenter}>
          {totalSurprises > 1 ? (
            <>
              {intl.formatMessage(
                {
                  id: "myPages.surprises.giftsWaiting",
                  defaultMessage:
                    "You have <b>{amount}</b> gifts waiting for you!",
                },
                {
                  amount: totalSurprises,
                  b: (str) => <b>{str}</b>,
                }
              )}
              <br />
              {intl.formatMessage({
                id: "myPages.surprises.willExpire",
                defaultMessage: "Hurry up and use them before they expire!",
              })}
            </>
          ) : (
            intl.formatMessage({
              id: "myPages.surprises.giftWaiting",
              defaultMessage: "We have a special gift waiting for you!",
            })
          )}
        </p>
      </Typography>
      <Typography variant="Body/Supporting text (caption)/smRegular">
        <p>
          {intl.formatMessage({
            id: "myPages.surprises.findGifts",
            defaultMessage: "You'll find all your gifts in 'My benefits'",
          })}
        </p>
      </Typography>

      <Button
        variant="Primary"
        onPress={onOpen}
        size="Medium"
        autoFocus
        typography="Body/Paragraph/mdBold"
        className={styles.widthFull}
      >
        {intl.formatMessage(
          {
            id: "myPages.surprises.openGifts",
            defaultMessage: "Open {amount, plural, one {gift} other {gifts}}",
          },
          { amount: totalSurprises }
        )}
      </Button>
    </Card>
  )
}
