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:
@@ -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({
|
||||
<html>
|
||||
<body>
|
||||
<div className={styles.layout}>
|
||||
<h1>{intl.formatMessage({ id: "Something went really wrong!" })}</h1>
|
||||
<h1>Something went really wrong!</h1>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -167,7 +167,9 @@ export default function BookingWidgetClient({
|
||||
}, [methods, selectedLocation])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window !== "undefined" && !selectedBookingCode) {
|
||||
if (!window?.sessionStorage || !window?.localStorage) return
|
||||
|
||||
if (!selectedBookingCode) {
|
||||
const storedBookingCode = localStorage.getItem("bookingCode")
|
||||
const initialBookingCode: BookingCodeSchema | undefined =
|
||||
storedBookingCode && isValidJson(storedBookingCode)
|
||||
|
||||
@@ -131,6 +131,8 @@ export default function Search({ locations, handlePressEnter }: SearchProps) {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!window?.sessionStorage || !window?.localStorage) return
|
||||
|
||||
const searchData = sessionStorage.getItem(sessionStorageKey)
|
||||
const searchHistory = localStorage.getItem(localStorageKey)
|
||||
const payload: SetStorageData["payload"] = {}
|
||||
|
||||
@@ -236,6 +236,7 @@
|
||||
"Extras to your booking": "Tillæg til din booking",
|
||||
"FAQ": "Ofte stillede spørgsmål",
|
||||
"Failed to add to calendar": "Fejl ved tilføjelse til kalender",
|
||||
"Failed to copy": "Kunne ikke kopiere",
|
||||
"Failed to delete credit card, please try again later.": "Kunne ikke slette kreditkort. Prøv venligst igen senere.",
|
||||
"Failed to submit form, please try again later.": "Failed to submit form, please try again later.",
|
||||
"Failed to unlink account": "Failed to unlink account",
|
||||
|
||||
@@ -237,6 +237,7 @@
|
||||
"Extras to your booking": "Extras zu Ihrer Buchung",
|
||||
"FAQ": "Häufig gestellte Fragen",
|
||||
"Failed to add to calendar": "Fehler beim Hinzufügen zum Kalender",
|
||||
"Failed to copy": "Kopieren fehlgeschlagen",
|
||||
"Failed to delete credit card, please try again later.": "Kreditkarte konnte nicht gelöscht werden. Bitte versuchen Sie es später noch einmal.",
|
||||
"Failed to submit form, please try again later.": "Failed to submit form, please try again later.",
|
||||
"Failed to unlink account": "Failed to unlink account",
|
||||
|
||||
@@ -241,6 +241,7 @@
|
||||
"Extras to your booking": "Extras to your booking",
|
||||
"FAQ": "FAQ",
|
||||
"Failed to add to calendar": "Failed to add to calendar",
|
||||
"Failed to copy": "Failed to copy",
|
||||
"Failed to delete credit card, please try again later.": "Failed to delete credit card, please try again later.",
|
||||
"Failed to submit form, please try again later.": "Failed to submit form, please try again later.",
|
||||
"Failed to unlink account": "Failed to unlink account",
|
||||
|
||||
@@ -236,6 +236,7 @@
|
||||
"Extras to your booking": "Varauksessa lisäpalveluita",
|
||||
"FAQ": "Usein kysytyt kysymykset",
|
||||
"Failed to add to calendar": "Virhe kalenteriin lisäämisessä",
|
||||
"Failed to copy": "Kopiointi epäonnistui",
|
||||
"Failed to delete credit card, please try again later.": "Luottokortin poistaminen epäonnistui, yritä myöhemmin uudelleen.",
|
||||
"Failed to submit form, please try again later.": "Failed to submit form, please try again later.",
|
||||
"Failed to unlink account": "Failed to unlink account",
|
||||
|
||||
@@ -235,6 +235,7 @@
|
||||
"Extras to your booking": "Tilvalg til bestillingen din",
|
||||
"FAQ": "Ofte stilte spørsmål",
|
||||
"Failed to add to calendar": "Feil ved tilføyelse til kalender",
|
||||
"Failed to copy": "Kunne ikke kopiere",
|
||||
"Failed to delete credit card, please try again later.": "Kunne ikke slette kredittkortet, prøv igjen senere.",
|
||||
"Failed to submit form, please try again later.": "Failed to submit form, please try again later.",
|
||||
"Failed to unlink account": "Failed to unlink account",
|
||||
|
||||
@@ -235,6 +235,7 @@
|
||||
"Extras to your booking": "Extra tillval till din bokning",
|
||||
"FAQ": "FAQ",
|
||||
"Failed to add to calendar": "Misslyckades att lägga till i kalender",
|
||||
"Failed to copy": "Kunde inte kopiera",
|
||||
"Failed to delete credit card, please try again later.": "Det gick inte att ta bort kreditkortet, försök igen senare.",
|
||||
"Failed to submit form, please try again later.": "Failed to submit form, please try again later.",
|
||||
"Failed to unlink account": "Failed to unlink account",
|
||||
|
||||
Reference in New Issue
Block a user