From 6fad2a6022b25397b5c1295fffca615134690452 Mon Sep 17 00:00:00 2001 From: Christian Andolf Date: Mon, 19 May 2025 10:58:14 +0200 Subject: [PATCH] fix: handle non loaded surprises in case they're returned as null from server --- apps/scandic-web/components/MyPages/Surprises/Client.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/scandic-web/components/MyPages/Surprises/Client.tsx b/apps/scandic-web/components/MyPages/Surprises/Client.tsx index 92b747db2..f20192486 100644 --- a/apps/scandic-web/components/MyPages/Surprises/Client.tsx +++ b/apps/scandic-web/components/MyPages/Surprises/Client.tsx @@ -28,7 +28,6 @@ import Slide from "./Slide" import styles from "./surprises.module.css" import type { SurprisesProps } from "@/types/components/blocks/surprises" -import type { Surprise } from "@/types/components/myPages/rewards" const MotionModal = motion.create(Modal) @@ -43,9 +42,7 @@ export default function SurprisesNotification({ const [showSurprises, setShowSurprises] = useState(false) const utils = trpc.useUtils() - const { data: surprises } = trpc.contentstack.rewards.surprises.useQuery< - Surprise[] - >( + const { data } = trpc.contentstack.rewards.surprises.useQuery( { lang, }, @@ -56,6 +53,8 @@ export default function SurprisesNotification({ } ) + const surprises = data ?? [] + const unwrap = trpc.contentstack.rewards.unwrap.useMutation({ onSuccess: () => { utils.contentstack.rewards.current.invalidate({ lang })