From 7563db9dbc2ce524e3d7c1618af460b548bd7c09 Mon Sep 17 00:00:00 2001 From: Linus Flood Date: Tue, 11 Mar 2025 10:49:56 +0000 Subject: [PATCH] Merged in fix/intl-global-error (pull request #1510) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- apps/scandic-web/app/global-error.tsx | 5 +---- .../DynamicContent/Overview/Buttons/CopyButton.tsx | 12 ++++++++---- .../DynamicContent/Rewards/Redeem/Flows/Campaign.tsx | 8 ++++++-- apps/scandic-web/components/BookingWidget/Client.tsx | 4 +++- .../Forms/BookingWidget/FormContent/Search/index.tsx | 2 ++ apps/scandic-web/i18n/dictionaries/da.json | 1 + apps/scandic-web/i18n/dictionaries/de.json | 1 + apps/scandic-web/i18n/dictionaries/en.json | 1 + apps/scandic-web/i18n/dictionaries/fi.json | 1 + apps/scandic-web/i18n/dictionaries/no.json | 1 + apps/scandic-web/i18n/dictionaries/sv.json | 1 + 11 files changed, 26 insertions(+), 11 deletions(-) diff --git a/apps/scandic-web/app/global-error.tsx b/apps/scandic-web/app/global-error.tsx index e317cfba4..1ff7f50d3 100644 --- a/apps/scandic-web/app/global-error.tsx +++ b/apps/scandic-web/app/global-error.tsx @@ -2,7 +2,6 @@ import * as Sentry from "@sentry/nextjs" import { useEffect } from "react" -import { useIntl } from "react-intl" import styles from "./global-error.module.css" @@ -13,8 +12,6 @@ export default function GlobalError({ }) { console.log({ global_error: error }) - const intl = useIntl() - useEffect(() => { Sentry.captureException(error) }, [error]) @@ -23,7 +20,7 @@ export default function GlobalError({
-

{intl.formatMessage({ id: "Something went really wrong!" })}

+

Something went really wrong!

diff --git a/apps/scandic-web/components/Blocks/DynamicContent/Overview/Buttons/CopyButton.tsx b/apps/scandic-web/components/Blocks/DynamicContent/Overview/Buttons/CopyButton.tsx index 3ed077ab3..b157871f3 100644 --- a/apps/scandic-web/components/Blocks/DynamicContent/Overview/Buttons/CopyButton.tsx +++ b/apps/scandic-web/components/Blocks/DynamicContent/Overview/Buttons/CopyButton.tsx @@ -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 ( diff --git a/apps/scandic-web/components/Blocks/DynamicContent/Rewards/Redeem/Flows/Campaign.tsx b/apps/scandic-web/components/Blocks/DynamicContent/Rewards/Redeem/Flows/Campaign.tsx index 58c9e037e..3d6202841 100644 --- a/apps/scandic-web/components/Blocks/DynamicContent/Rewards/Redeem/Flows/Campaign.tsx +++ b/apps/scandic-web/components/Blocks/DynamicContent/Rewards/Redeem/Flows/Campaign.tsx @@ -42,8 +42,12 @@ export default function Campaign() {