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"
|
||||
|
||||
@@ -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"] = {}
|
||||
|
||||
Reference in New Issue
Block a user