Merged in feat/SW-286-collectionPage (pull request #765)

Feat(SW-286): CollectionPage

Approved-by: Erik Tiekstra
Approved-by: Fredrik Thorsson
This commit is contained in:
Matilda Landström
2024-11-04 12:10:51 +00:00
parent dabdd597e2
commit d5efaa686c
45 changed files with 918 additions and 35 deletions

View File

@@ -30,6 +30,16 @@ export const extendedPageLinkSchema = pageLinkSchema.merge(
}),
})
)
export const collectionPageSchema = z
.object({
__typename: z.literal(ContentEnum.blocks.CollectionPage),
})
.merge(extendedPageLinkSchema)
export const collectionPageRefSchema = z.object({
__typename: z.literal(ContentEnum.blocks.CollectionPage),
system: systemSchema,
})
export const contentPageSchema = z
.object({
@@ -67,6 +77,7 @@ export const loyaltyPageRefSchema = z.object({
type Data =
| z.output<typeof accountPageSchema>
| z.output<typeof contentPageSchema>
| z.output<typeof collectionPageSchema>
| z.output<typeof hotelPageSchema>
| z.output<typeof loyaltyPageSchema>
| Object
@@ -83,6 +94,7 @@ export function transform(data: Data) {
url: removeMultipleSlashes(`/${data.system.locale}/${data.url}`),
}
case ContentEnum.blocks.ContentPage:
case ContentEnum.blocks.CollectionPage:
case ContentEnum.blocks.LoyaltyPage:
// TODO: Once all links use this transform
// `web` can be removed and not to be worried
@@ -102,6 +114,7 @@ export function transform(data: Data) {
type RefData =
| z.output<typeof accountPageRefSchema>
| z.output<typeof collectionPageRefSchema>
| z.output<typeof contentPageRefSchema>
| z.output<typeof hotelPageRefSchema>
| z.output<typeof loyaltyPageRefSchema>
@@ -112,6 +125,7 @@ export function transformRef(data: RefData) {
switch (data.__typename) {
case ContentEnum.blocks.AccountPage:
case ContentEnum.blocks.ContentPage:
case ContentEnum.blocks.CollectionPage:
case ContentEnum.blocks.HotelPage:
case ContentEnum.blocks.LoyaltyPage:
return data.system