Merged in fix/intl-global-error (pull request #1510)
Fix: Error message when copy fail. Null check on localstorage. Removed Intl from global-error.tsx * Error message if failed to copy * Use try/catch instead Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -14,10 +14,14 @@ export default function CopyButton({ membershipNumber }: CopyButtonProps) {
|
||||
const intl = useIntl()
|
||||
|
||||
function handleCopy() {
|
||||
navigator.clipboard.writeText(membershipNumber)
|
||||
toast.success(
|
||||
intl.formatMessage({ id: "Membership ID copied to clipboard" })
|
||||
)
|
||||
try {
|
||||
navigator.clipboard.writeText(membershipNumber)
|
||||
toast.success(
|
||||
intl.formatMessage({ id: "Membership ID copied to clipboard" })
|
||||
)
|
||||
} catch {
|
||||
toast.error(intl.formatMessage({ id: "Failed to copy" }))
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -42,8 +42,12 @@ export default function Campaign() {
|
||||
<footer className={styles.modalFooter}>
|
||||
<Button
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(reward.operaRewardId)
|
||||
toast.success(intl.formatMessage({ id: "Copied to clipboard" }))
|
||||
try {
|
||||
navigator.clipboard.writeText(reward.operaRewardId)
|
||||
toast.success(intl.formatMessage({ id: "Copied to clipboard" }))
|
||||
} catch {
|
||||
toast.error(intl.formatMessage({ id: "Failed to copy" }))
|
||||
}
|
||||
}}
|
||||
type="button"
|
||||
variant="icon"
|
||||
|
||||
Reference in New Issue
Block a user