diff --git a/components/Footer/Navigation/SecondaryNav/index.tsx b/components/Footer/Navigation/SecondaryNav/index.tsx index f731c67a9..3f631f809 100644 --- a/components/Footer/Navigation/SecondaryNav/index.tsx +++ b/components/Footer/Navigation/SecondaryNav/index.tsx @@ -37,7 +37,7 @@ export default function FooterSecondaryNav({ `${link.type}_${lang}` as keyof typeof AppDownLoadLinks ] } - alt={link.href.title} + alt="" width={125} height={40} /> diff --git a/server/routers/contentstack/base/output.ts b/server/routers/contentstack/base/output.ts index 3dedb5096..9b015969f 100644 --- a/server/routers/contentstack/base/output.ts +++ b/server/routers/contentstack/base/output.ts @@ -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 .object({ all_footer: z.object({ @@ -339,26 +353,11 @@ export const validateFooterConfigSchema = z main_links: z.array(validateLinkItem), app_downloads: z.object({ title: z.string(), - links: z.array( - z.object({ - type: z.string(), - href: validateExternalLink, - }) - ), + links: validateLinksWithType, }), - secondary_links: z.array( - z.object({ - title: z.string(), - links: z.array(validateLinkItem), - }) - ), + secondary_links: validateSecondaryLinks, social_media: z.object({ - links: z.array( - z.object({ - type: z.string(), - href: validateExternalLink, - }) - ), + links: validateLinksWithType, }), tertiary_links: z.array(validateLinkItem), }) diff --git a/server/routers/contentstack/base/query.ts b/server/routers/contentstack/base/query.ts index bde79d886..c2f0c948a 100644 --- a/server/routers/contentstack/base/query.ts +++ b/server/routers/contentstack/base/query.ts @@ -583,7 +583,6 @@ export const baseQueryRouter = router({ const connections = getFooterConnections(validatedFooterRefs.data) 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 }) console.info( "contentstack.footer start", diff --git a/types/components/footer/navigation.ts b/types/components/footer/navigation.ts index 37c0a3600..e17c7d65b 100644 --- a/types/components/footer/navigation.ts +++ b/types/components/footer/navigation.ts @@ -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" -export type FooterLink = { - isExternal: boolean - openInNewTab: boolean - title: string | undefined - url: string -} +export type FooterLink = z.output + export type FooterMainNavProps = { mainLinks: FooterLink[] } -type FooterSecondaryNavGroup = { - title: string - links: FooterLink[] -} -type FooterLinkWithType = { - href?: - | { - href: string - title: string - } - | undefined - type: string -} +type FooterSecondaryNavGroup = z.output + +type FooterLinkWithType = z.output type FooterAppDownloads = { title: string - links: FooterLinkWithType[] + links: FooterLinkWithType } type FooterSocialMedia = { - links: FooterLinkWithType[] + links: FooterLinkWithType } export type FooterSecondaryNavProps = { - secondaryLinks: FooterSecondaryNavGroup[] + secondaryLinks: FooterSecondaryNavGroup appDownloads: FooterAppDownloads }