refactor: zod validation and pr comments

This commit is contained in:
Christel Westerberg
2024-04-29 14:00:24 +02:00
parent 9f0b044daa
commit d9f1470eb7
31 changed files with 222 additions and 207 deletions

View File

@@ -31,6 +31,7 @@ export const loyaltyPageQueryRouter = router({
)
if (!validatedLoyaltyPage.success) {
console.error(validatedLoyaltyPage.error)
throw badRequestError()
}
@@ -68,15 +69,13 @@ export const loyaltyPageQueryRouter = router({
cards: block.card_grid.cards.map((card) => {
return {
...card,
link:
card.referenceConnection.totalCount > 0
? {
href: card.referenceConnection.edges[0].node
.url,
title:
card.referenceConnection.edges[0].node.title,
}
: undefined,
link: card.referenceConnection.totalCount
? {
href: card.referenceConnection.edges[0].node.url,
title:
card.referenceConnection.edges[0].node.title,
}
: undefined,
}
}),
},
@@ -86,17 +85,16 @@ export const loyaltyPageQueryRouter = router({
...block,
dynamic_content: {
...block.dynamic_content,
link:
block.dynamic_content.link.pageConnection.totalCount > 0
? {
text: block.dynamic_content.link.text,
href: block.dynamic_content.link.pageConnection
.edges[0].node.url,
title:
block.dynamic_content.link.pageConnection.edges[0]
.node.title,
}
: undefined,
link: block.dynamic_content.link.pageConnection.totalCount
? {
text: block.dynamic_content.link.text,
href: block.dynamic_content.link.pageConnection
.edges[0].node.url,
title:
block.dynamic_content.link.pageConnection.edges[0]
.node.title,
}
: undefined,
},
}
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksContent: