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
73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
"use client"
|
|
|
|
import { useIntl } from "react-intl"
|
|
|
|
import Body from "@scandic-hotels/design-system/Body"
|
|
import Caption from "@scandic-hotels/design-system/Caption"
|
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
|
import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton"
|
|
import Title from "@scandic-hotels/design-system/Title"
|
|
import { toast } from "@scandic-hotels/design-system/Toast"
|
|
|
|
import { RewardIcon } from "../../RewardIcon"
|
|
|
|
import styles from "../redeem.module.css"
|
|
|
|
import type { Campaign } from "@scandic-hotels/trpc/types/rewards"
|
|
|
|
export default function Campaign({ reward }: { reward: Campaign }) {
|
|
const intl = useIntl()
|
|
|
|
return (
|
|
<>
|
|
<div className={styles.modalContent}>
|
|
<RewardIcon rewardId={reward.reward_id} />
|
|
<Title level="h3" textAlign="center" textTransform="regular">
|
|
{reward.label}
|
|
</Title>
|
|
<Body textAlign="center">{reward.description}</Body>
|
|
<div className={styles.rewardBadge}>
|
|
<Caption textAlign="center" color="uiTextHighContrast" type="bold">
|
|
{intl.formatMessage({
|
|
defaultMessage: "Promo code",
|
|
})}
|
|
</Caption>
|
|
<Caption textAlign="center" color="uiTextHighContrast">
|
|
{reward.operaRewardId}
|
|
</Caption>
|
|
</div>
|
|
</div>
|
|
<footer className={styles.modalFooter}>
|
|
<Button
|
|
onClick={() => {
|
|
try {
|
|
navigator.clipboard.writeText(reward.operaRewardId)
|
|
toast.success(
|
|
intl.formatMessage({
|
|
defaultMessage: "Copied to clipboard",
|
|
})
|
|
)
|
|
} catch {
|
|
toast.error(
|
|
intl.formatMessage({
|
|
defaultMessage: "Failed to copy",
|
|
})
|
|
)
|
|
}
|
|
}}
|
|
type="button"
|
|
variant="icon"
|
|
size="small"
|
|
theme="base"
|
|
intent="primary"
|
|
>
|
|
<MaterialIcon icon="content_copy" color="CurrentColor" />
|
|
{intl.formatMessage({
|
|
defaultMessage: "Copy promotion code",
|
|
})}
|
|
</Button>
|
|
</footer>
|
|
</>
|
|
)
|
|
}
|