feat(SW-285): Add support for sidebar
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
Block,
|
||||
ContentPage,
|
||||
ContentPageDataRaw,
|
||||
Sidebar,
|
||||
validateContentPageSchema,
|
||||
} from "./output"
|
||||
import {
|
||||
@@ -25,6 +26,7 @@ import {
|
||||
import {
|
||||
CardsGridEnum,
|
||||
ContentBlocksTypenameEnum,
|
||||
SidebarTypenameEnum,
|
||||
} from "@/types/components/content/enums"
|
||||
import {
|
||||
TrackingChannelEnum,
|
||||
@@ -145,11 +147,29 @@ export const contentPageQueryRouter = router({
|
||||
})
|
||||
: null
|
||||
|
||||
const sidebar = response.data.content_page.sidebar
|
||||
? response.data.content_page.sidebar.map((item: any) => {
|
||||
switch (item.__typename) {
|
||||
case SidebarTypenameEnum.ContentPageSidebarJoinLoyaltyContact:
|
||||
return {
|
||||
...item,
|
||||
join_loyalty_contact: {
|
||||
...item.join_loyalty_contact,
|
||||
button: makeButtonObject(item.join_loyalty_contact.button),
|
||||
},
|
||||
}
|
||||
default:
|
||||
return item
|
||||
}
|
||||
})
|
||||
: null
|
||||
|
||||
const heroImage = makeImageVaultImage(content_page.hero_image)
|
||||
const validatedContentPage = validateContentPageSchema.safeParse({
|
||||
content_page: {
|
||||
...content_page,
|
||||
blocks: processedBlocks,
|
||||
sidebar,
|
||||
hero_image: heroImage,
|
||||
},
|
||||
})
|
||||
@@ -169,6 +189,7 @@ export const contentPageQueryRouter = router({
|
||||
...restContentPage,
|
||||
heroImage,
|
||||
blocks: blocks as Block[],
|
||||
sidebar: sidebar as Sidebar[],
|
||||
}
|
||||
|
||||
const tracking: TrackingSDKPageData = {
|
||||
|
||||
Reference in New Issue
Block a user