"use client"

import { useParams } from "next/navigation"
import { useIntl } from "react-intl"

import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton"

import Dialog from "@/components/Dialog"

import type { LangParams } from "@/types/params"

export function UnlinkSAS() {
  const intl = useIntl()
  const params = useParams<LangParams>()

  return (
    <Dialog
      titleText={intl.formatMessage({
        id: "partnerSas.unlinkAccount",
        defaultMessage: "Are you sure you want to unlink your account?",
      })}
      bodyText={intl.formatMessage({
        id: "partnerSas.unlinkAccountWarning",
        defaultMessage:
          "This will remove any membership level upgrades gained from the linking. You can re-link your accounts again in 30 days.",
      })}
      cancelButtonText={intl.formatMessage({
        id: "common.goBack",
        defaultMessage: "Go back",
      })}
      proceedText={intl.formatMessage({
        id: "partnerSas.yesUnlinkAccount",
        defaultMessage: "Yes, unlink my accounts",
      })}
      proceedHref={`/${params.lang}/sas-x-scandic/login?intent=unlink`}
      trigger={
        <Button intent="text" theme="base">
          {intl.formatMessage({
            id: "partnerSas.unlinkAccounts",
            defaultMessage: "Unlink accounts",
          })}
          <MaterialIcon icon="chevron_right" size={20} color="CurrentColor" />
        </Button>
      }
    />
  )
}
