Feat/lokalise rebuild * chore(lokalise): update translation ids * chore(lokalise): easier to switch between projects * chore(lokalise): update translation ids * . * . * . * . * . * . * chore(lokalise): update translation ids * chore(lokalise): update translation ids * . * . * . * chore(lokalise): update translation ids * chore(lokalise): update translation ids * . * . * chore(lokalise): update translation ids * chore(lokalise): update translation ids * chore(lokalise): new translations * merge * switch to errors for missing id's * merge * sync translations Approved-by: Linus Flood
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
"use client"
|
|
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { Button } from "@scandic-hotels/design-system/Button"
|
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
|
import { toast } from "@scandic-hotels/design-system/Toast"
|
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
|
|
|
import styles from "./copyMembershipIdButton.module.css"
|
|
|
|
interface CopyMembershipIdButtonProps {
|
|
membershipNumber: string
|
|
}
|
|
|
|
export default function CopyMembershipIdButton({
|
|
membershipNumber,
|
|
}: CopyMembershipIdButtonProps) {
|
|
const intl = useIntl()
|
|
|
|
function handleCopy() {
|
|
try {
|
|
navigator.clipboard.writeText(membershipNumber)
|
|
toast.success(
|
|
intl.formatMessage({
|
|
id: "myPages.membershipIdCopied",
|
|
defaultMessage: "Membership ID copied to clipboard",
|
|
})
|
|
)
|
|
} catch {
|
|
toast.error(
|
|
intl.formatMessage({
|
|
id: "errorMessage.copyFailed",
|
|
defaultMessage: "Failed to copy",
|
|
})
|
|
)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className={styles.container}>
|
|
<Typography variant="Body/Supporting text (caption)/smBold">
|
|
<code data-hj-suppress className={styles.membershipCode}>
|
|
{membershipNumber}
|
|
</code>
|
|
</Typography>
|
|
<Button
|
|
onClick={handleCopy}
|
|
className={styles.copyButton}
|
|
variant="Text"
|
|
size="Small"
|
|
>
|
|
<MaterialIcon icon="content_copy" color="CurrentColor" />
|
|
</Button>
|
|
</div>
|
|
)
|
|
}
|