Files
web/apps/scandic-web/components/Blocks/DynamicContent/Overview/Buttons/CopyButton.tsx
Joakim Jäderberg 72f4f72a17 Merged in SW-3317-move-toast-to-design-system (pull request #2716)
SW-3317 move toast to design system

* chore: Move toast to design-system and add interaction tests

* Move toast to design-system and add storybook tests

* Merge branch 'master' of bitbucket.org:scandic-swap/web into SW-3317-move-toast-to-design-system

* merge

* move sonner dependency to @scandic-hotels/design-system


Approved-by: Anton Gunnarsson
2025-08-27 13:03:17 +00:00

46 lines
1.1 KiB
TypeScript

"use client"
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 { toast } from "@scandic-hotels/design-system/Toast"
import styles from "./copybutton.module.css"
import type { CopyButtonProps } from "@/types/components/myPages/membership"
export default function CopyButton({ membershipNumber }: CopyButtonProps) {
const intl = useIntl()
function handleCopy() {
try {
navigator.clipboard.writeText(membershipNumber)
toast.success(
intl.formatMessage({
defaultMessage: "Membership ID copied to clipboard",
})
)
} catch {
toast.error(
intl.formatMessage({
defaultMessage: "Failed to copy",
})
)
}
}
return (
<Button
onClick={handleCopy}
className={styles.button}
type="button"
variant="icon"
size="small"
intent="tertiary"
>
<MaterialIcon icon="content_copy" color="CurrentColor" />
</Button>
)
}