From 4afddfc978b8ae0aef32722ded81e53c4abcd2b5 Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust Date: Wed, 18 Sep 2024 14:21:28 +0200 Subject: [PATCH] fix(CompensationsPreview): clean stega from salaries data string Since salaries data is encoded as a simple string, Sanity assumes it's fine to apply stega to it. But JSON.parse begs to differ... --- src/compensations/CompensationsPreview.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/compensations/CompensationsPreview.tsx b/src/compensations/CompensationsPreview.tsx index 131e2aaeb..7e7fb6a03 100644 --- a/src/compensations/CompensationsPreview.tsx +++ b/src/compensations/CompensationsPreview.tsx @@ -1,4 +1,5 @@ "use client"; +import { stegaClean } from "@sanity/client/stega"; import { QueryResponseInitial, useQuery } from "@sanity/react-loader"; import { Suspense } from "react"; @@ -18,7 +19,7 @@ const CompensationsPreview = ({ initialCompensations, initialLocations, }: CompensationsPreviewProps) => { - const { data } = useQuery( + const { data: compensationsData } = useQuery( COMPENSATIONS_PAGE_QUERY, { slug: initialCompensations.data.slug.current }, { initial: initialCompensations }, @@ -29,10 +30,17 @@ const CompensationsPreview = ({ { initial: initialLocations }, ); + compensationsData.salariesByLocation = stegaClean( + compensationsData.salariesByLocation, + ); + return ( locationData && ( - + ) );