feat(sw-187): updated typings to use schema
This commit is contained in:
@@ -37,7 +37,7 @@ export default function FooterSecondaryNav({
|
|||||||
`${link.type}_${lang}` as keyof typeof AppDownLoadLinks
|
`${link.type}_${lang}` as keyof typeof AppDownLoadLinks
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
alt={link.href.title}
|
alt=""
|
||||||
width={125}
|
width={125}
|
||||||
height={40}
|
height={40}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -331,6 +331,20 @@ export const validateLinkItem = z
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const validateSecondaryLinks = z.array(
|
||||||
|
z.object({
|
||||||
|
title: z.string(),
|
||||||
|
links: z.array(validateLinkItem),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
export const validateLinksWithType = z.array(
|
||||||
|
z.object({
|
||||||
|
type: z.string(),
|
||||||
|
href: validateExternalLink,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
export const validateFooterConfigSchema = z
|
export const validateFooterConfigSchema = z
|
||||||
.object({
|
.object({
|
||||||
all_footer: z.object({
|
all_footer: z.object({
|
||||||
@@ -339,26 +353,11 @@ export const validateFooterConfigSchema = z
|
|||||||
main_links: z.array(validateLinkItem),
|
main_links: z.array(validateLinkItem),
|
||||||
app_downloads: z.object({
|
app_downloads: z.object({
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
links: z.array(
|
links: validateLinksWithType,
|
||||||
z.object({
|
|
||||||
type: z.string(),
|
|
||||||
href: validateExternalLink,
|
|
||||||
})
|
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
secondary_links: z.array(
|
secondary_links: validateSecondaryLinks,
|
||||||
z.object({
|
|
||||||
title: z.string(),
|
|
||||||
links: z.array(validateLinkItem),
|
|
||||||
})
|
|
||||||
),
|
|
||||||
social_media: z.object({
|
social_media: z.object({
|
||||||
links: z.array(
|
links: validateLinksWithType,
|
||||||
z.object({
|
|
||||||
type: z.string(),
|
|
||||||
href: validateExternalLink,
|
|
||||||
})
|
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
tertiary_links: z.array(validateLinkItem),
|
tertiary_links: z.array(validateLinkItem),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -583,7 +583,6 @@ export const baseQueryRouter = router({
|
|||||||
const connections = getFooterConnections(validatedFooterRefs.data)
|
const connections = getFooterConnections(validatedFooterRefs.data)
|
||||||
const footerUID = responseRef.data.all_footer.items[0].system.uid
|
const footerUID = responseRef.data.all_footer.items[0].system.uid
|
||||||
|
|
||||||
// There's currently no error handling/validation for the responseRef, should it be added?
|
|
||||||
getFooterCounter.add(1, { lang: lang })
|
getFooterCounter.add(1, { lang: lang })
|
||||||
console.info(
|
console.info(
|
||||||
"contentstack.footer start",
|
"contentstack.footer start",
|
||||||
|
|||||||
@@ -1,40 +1,34 @@
|
|||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
|
import {
|
||||||
|
validateLinkItem,
|
||||||
|
validateLinksWithType,
|
||||||
|
validateSecondaryLinks,
|
||||||
|
} from "@/server/routers/contentstack/base/output"
|
||||||
|
|
||||||
import type { LanguageSwitcherData } from "@/types/requests/languageSwitcher"
|
import type { LanguageSwitcherData } from "@/types/requests/languageSwitcher"
|
||||||
|
|
||||||
export type FooterLink = {
|
export type FooterLink = z.output<typeof validateLinkItem>
|
||||||
isExternal: boolean
|
|
||||||
openInNewTab: boolean
|
|
||||||
title: string | undefined
|
|
||||||
url: string
|
|
||||||
}
|
|
||||||
export type FooterMainNavProps = {
|
export type FooterMainNavProps = {
|
||||||
mainLinks: FooterLink[]
|
mainLinks: FooterLink[]
|
||||||
}
|
}
|
||||||
|
|
||||||
type FooterSecondaryNavGroup = {
|
type FooterSecondaryNavGroup = z.output<typeof validateSecondaryLinks>
|
||||||
title: string
|
|
||||||
links: FooterLink[]
|
type FooterLinkWithType = z.output<typeof validateLinksWithType>
|
||||||
}
|
|
||||||
type FooterLinkWithType = {
|
|
||||||
href?:
|
|
||||||
| {
|
|
||||||
href: string
|
|
||||||
title: string
|
|
||||||
}
|
|
||||||
| undefined
|
|
||||||
type: string
|
|
||||||
}
|
|
||||||
|
|
||||||
type FooterAppDownloads = {
|
type FooterAppDownloads = {
|
||||||
title: string
|
title: string
|
||||||
links: FooterLinkWithType[]
|
links: FooterLinkWithType
|
||||||
}
|
}
|
||||||
|
|
||||||
type FooterSocialMedia = {
|
type FooterSocialMedia = {
|
||||||
links: FooterLinkWithType[]
|
links: FooterLinkWithType
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FooterSecondaryNavProps = {
|
export type FooterSecondaryNavProps = {
|
||||||
secondaryLinks: FooterSecondaryNavGroup[]
|
secondaryLinks: FooterSecondaryNavGroup
|
||||||
appDownloads: FooterAppDownloads
|
appDownloads: FooterAppDownloads
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user