Files
web/apps/scandic-web/components/Profile/ManagePreferencesButton/index.tsx
Matilda Landström 1239f0c662 Merged in feat/SW-1711-SW-2077-icons (pull request #1709)
Fix(SW-1711)/(SW-2077): Export icons individually

* fix(SW-1711): export icons individually


Approved-by: Michael Zetterberg
Approved-by: Erik Tiekstra
2025-04-07 07:25:25 +00:00

53 lines
1.4 KiB
TypeScript

"use client"
import { useIntl } from "react-intl"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import { trpc } from "@/lib/trpc/client"
import Button from "@/components/TempDesignSystem/Button"
import { toast } from "@/components/TempDesignSystem/Toasts"
import styles from "./managePreferencesButton.module.css"
export default function ManagePreferencesButton() {
const intl = useIntl()
const generatePreferencesLink = trpc.user.generatePreferencesLink.useMutation(
{
onSuccess: (preferencesLink) => {
if (preferencesLink) {
window.open(preferencesLink, "_blank")
} else {
toast.error(
intl.formatMessage({
id: "It is not posible to manage your communication preferences right now, please try again later or contact support if the problem persists.",
})
)
}
},
onError: () => {
toast.error(
intl.formatMessage({
id: "An error occurred trying to manage your preferences, please try again later.",
})
)
},
}
)
return (
<Button
className={styles.managePreferencesButton}
variant="icon"
theme="base"
intent="text"
onClick={() => generatePreferencesLink.mutate()}
wrapping
>
<MaterialIcon icon="arrow_forward" color="CurrentColor" />
{intl.formatMessage({ id: "Manage preferences" })}
</Button>
)
}