fix: zod validate after cruching data
This commit is contained in:
@@ -85,18 +85,6 @@ export const loyaltyPageQueryRouter = router({
|
||||
throw notFound(response)
|
||||
}
|
||||
|
||||
const validatedLoyaltyPage = validateLoyaltyPageSchema.safeParse(
|
||||
response.data.loyalty_page
|
||||
)
|
||||
|
||||
if (!validatedLoyaltyPage.success) {
|
||||
console.error(
|
||||
`Failed to validate Loyaltypage Data - (lang: ${lang}, uid: ${uid})`
|
||||
)
|
||||
console.error(validatedLoyaltyPage.error)
|
||||
return null
|
||||
}
|
||||
|
||||
const blocks = response.data.loyalty_page.blocks
|
||||
? response.data.loyalty_page.blocks.map((block: any) => {
|
||||
switch (block.__typename) {
|
||||
@@ -190,7 +178,7 @@ export const loyaltyPageQueryRouter = router({
|
||||
})
|
||||
: null
|
||||
|
||||
const loyaltyPage: LoyaltyPage = {
|
||||
const loyaltyPage = {
|
||||
heading: response.data.loyalty_page.heading,
|
||||
preamble: response.data.loyalty_page.preamble,
|
||||
heroImage: makeImageVaultImage(response.data.loyalty_page.hero_image),
|
||||
@@ -199,6 +187,16 @@ export const loyaltyPageQueryRouter = router({
|
||||
sidebar,
|
||||
}
|
||||
|
||||
const validatedLoyaltyPage =
|
||||
validateLoyaltyPageSchema.safeParse(loyaltyPage)
|
||||
if (!validatedLoyaltyPage.success) {
|
||||
console.error(
|
||||
`Failed to validate Loyaltypage Data - (lang: ${lang}, uid: ${uid})`
|
||||
)
|
||||
console.error(validatedLoyaltyPage.error)
|
||||
return null
|
||||
}
|
||||
|
||||
const loyaltyTrackingData: TrackingSDKPageData = {
|
||||
pageId: response.data.loyalty_page.system.uid,
|
||||
lang: response.data.loyalty_page.system.locale as Lang,
|
||||
|
||||
Reference in New Issue
Block a user