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 * as Sentry from "@sentry/nextjs"
|
||||||
import { useEffect } from "react"
|
import { useEffect } from "react"
|
||||||
import { useIntl } from "react-intl"
|
|
||||||
|
|
||||||
import styles from "./global-error.module.css"
|
import styles from "./global-error.module.css"
|
||||||
|
|
||||||
@@ -13,8 +12,6 @@ export default function GlobalError({
|
|||||||
}) {
|
}) {
|
||||||
console.log({ global_error: error })
|
console.log({ global_error: error })
|
||||||
|
|
||||||
const intl = useIntl()
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Sentry.captureException(error)
|
Sentry.captureException(error)
|
||||||
}, [error])
|
}, [error])
|
||||||
@@ -23,7 +20,7 @@ export default function GlobalError({
|
|||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<div className={styles.layout}>
|
<div className={styles.layout}>
|
||||||
<h1>{intl.formatMessage({ id: "Something went really wrong!" })}</h1>
|
<h1>Something went really wrong!</h1>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -14,10 +14,14 @@ export default function CopyButton({ membershipNumber }: CopyButtonProps) {
|
|||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
|
|
||||||
function handleCopy() {
|
function handleCopy() {
|
||||||
navigator.clipboard.writeText(membershipNumber)
|
try {
|
||||||
toast.success(
|
navigator.clipboard.writeText(membershipNumber)
|
||||||
intl.formatMessage({ id: "Membership ID copied to clipboard" })
|
toast.success(
|
||||||
)
|
intl.formatMessage({ id: "Membership ID copied to clipboard" })
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
toast.error(intl.formatMessage({ id: "Failed to copy" }))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -42,8 +42,12 @@ export default function Campaign() {
|
|||||||
<footer className={styles.modalFooter}>
|
<footer className={styles.modalFooter}>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigator.clipboard.writeText(reward.operaRewardId)
|
try {
|
||||||
toast.success(intl.formatMessage({ id: "Copied to clipboard" }))
|
navigator.clipboard.writeText(reward.operaRewardId)
|
||||||
|
toast.success(intl.formatMessage({ id: "Copied to clipboard" }))
|
||||||
|
} catch {
|
||||||
|
toast.error(intl.formatMessage({ id: "Failed to copy" }))
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
type="button"
|
type="button"
|
||||||
variant="icon"
|
variant="icon"
|
||||||
|
|||||||
@@ -167,7 +167,9 @@ export default function BookingWidgetClient({
|
|||||||
}, [methods, selectedLocation])
|
}, [methods, selectedLocation])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof window !== "undefined" && !selectedBookingCode) {
|
if (!window?.sessionStorage || !window?.localStorage) return
|
||||||
|
|
||||||
|
if (!selectedBookingCode) {
|
||||||
const storedBookingCode = localStorage.getItem("bookingCode")
|
const storedBookingCode = localStorage.getItem("bookingCode")
|
||||||
const initialBookingCode: BookingCodeSchema | undefined =
|
const initialBookingCode: BookingCodeSchema | undefined =
|
||||||
storedBookingCode && isValidJson(storedBookingCode)
|
storedBookingCode && isValidJson(storedBookingCode)
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ export default function Search({ locations, handlePressEnter }: SearchProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!window?.sessionStorage || !window?.localStorage) return
|
||||||
|
|
||||||
const searchData = sessionStorage.getItem(sessionStorageKey)
|
const searchData = sessionStorage.getItem(sessionStorageKey)
|
||||||
const searchHistory = localStorage.getItem(localStorageKey)
|
const searchHistory = localStorage.getItem(localStorageKey)
|
||||||
const payload: SetStorageData["payload"] = {}
|
const payload: SetStorageData["payload"] = {}
|
||||||
|
|||||||
@@ -236,6 +236,7 @@
|
|||||||
"Extras to your booking": "Tillæg til din booking",
|
"Extras to your booking": "Tillæg til din booking",
|
||||||
"FAQ": "Ofte stillede spørgsmål",
|
"FAQ": "Ofte stillede spørgsmål",
|
||||||
"Failed to add to calendar": "Fejl ved tilføjelse til kalender",
|
"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 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 submit form, please try again later.": "Failed to submit form, please try again later.",
|
||||||
"Failed to unlink account": "Failed to unlink account",
|
"Failed to unlink account": "Failed to unlink account",
|
||||||
|
|||||||
@@ -237,6 +237,7 @@
|
|||||||
"Extras to your booking": "Extras zu Ihrer Buchung",
|
"Extras to your booking": "Extras zu Ihrer Buchung",
|
||||||
"FAQ": "Häufig gestellte Fragen",
|
"FAQ": "Häufig gestellte Fragen",
|
||||||
"Failed to add to calendar": "Fehler beim Hinzufügen zum Kalender",
|
"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 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 submit form, please try again later.": "Failed to submit form, please try again later.",
|
||||||
"Failed to unlink account": "Failed to unlink account",
|
"Failed to unlink account": "Failed to unlink account",
|
||||||
|
|||||||
@@ -241,6 +241,7 @@
|
|||||||
"Extras to your booking": "Extras to your booking",
|
"Extras to your booking": "Extras to your booking",
|
||||||
"FAQ": "FAQ",
|
"FAQ": "FAQ",
|
||||||
"Failed to add to calendar": "Failed to add to calendar",
|
"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 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 submit form, please try again later.": "Failed to submit form, please try again later.",
|
||||||
"Failed to unlink account": "Failed to unlink account",
|
"Failed to unlink account": "Failed to unlink account",
|
||||||
|
|||||||
@@ -236,6 +236,7 @@
|
|||||||
"Extras to your booking": "Varauksessa lisäpalveluita",
|
"Extras to your booking": "Varauksessa lisäpalveluita",
|
||||||
"FAQ": "Usein kysytyt kysymykset",
|
"FAQ": "Usein kysytyt kysymykset",
|
||||||
"Failed to add to calendar": "Virhe kalenteriin lisäämisessä",
|
"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 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 submit form, please try again later.": "Failed to submit form, please try again later.",
|
||||||
"Failed to unlink account": "Failed to unlink account",
|
"Failed to unlink account": "Failed to unlink account",
|
||||||
|
|||||||
@@ -235,6 +235,7 @@
|
|||||||
"Extras to your booking": "Tilvalg til bestillingen din",
|
"Extras to your booking": "Tilvalg til bestillingen din",
|
||||||
"FAQ": "Ofte stilte spørsmål",
|
"FAQ": "Ofte stilte spørsmål",
|
||||||
"Failed to add to calendar": "Feil ved tilføyelse til kalender",
|
"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 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 submit form, please try again later.": "Failed to submit form, please try again later.",
|
||||||
"Failed to unlink account": "Failed to unlink account",
|
"Failed to unlink account": "Failed to unlink account",
|
||||||
|
|||||||
@@ -235,6 +235,7 @@
|
|||||||
"Extras to your booking": "Extra tillval till din bokning",
|
"Extras to your booking": "Extra tillval till din bokning",
|
||||||
"FAQ": "FAQ",
|
"FAQ": "FAQ",
|
||||||
"Failed to add to calendar": "Misslyckades att lägga till i kalender",
|
"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 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 submit form, please try again later.": "Failed to submit form, please try again later.",
|
||||||
"Failed to unlink account": "Failed to unlink account",
|
"Failed to unlink account": "Failed to unlink account",
|
||||||
|
|||||||
Reference in New Issue
Block a user