diff --git a/components/Footer/Details/index.tsx b/components/Footer/Details/index.tsx index 70b7cffa2..7f0699439 100644 --- a/components/Footer/Details/index.tsx +++ b/components/Footer/Details/index.tsx @@ -21,11 +21,12 @@ function SocialIcon({ iconName }: SocialIconsProps) { export default async function FooterDetails({ socialMedia, + tertiaryLinks, }: FooterDetailsProps) { const lang = getLang() const { formatMessage } = await getIntl() const currentYear = new Date().getFullYear() - const { tertiaryLinks, languageSwitcher } = footer + const { languageSwitcher } = footer return (
@@ -68,18 +69,21 @@ export default async function FooterDetails({
diff --git a/components/Footer/index.tsx b/components/Footer/index.tsx index b571d13fb..a6f85bb80 100644 --- a/components/Footer/index.tsx +++ b/components/Footer/index.tsx @@ -19,7 +19,10 @@ export default async function Footer() { secondaryLinks={footerData.secondaryLinks} appDownloads={footerData.appDownloads} /> - + ) } diff --git a/lib/graphql/Fragments/Footer/Refs/TertiaryLinks.graphql b/lib/graphql/Fragments/Footer/Refs/TertiaryLinks.graphql new file mode 100644 index 000000000..d1fd47864 --- /dev/null +++ b/lib/graphql/Fragments/Footer/Refs/TertiaryLinks.graphql @@ -0,0 +1,22 @@ +#import "../../Refs/LoyaltyPage/LoyaltyPage.graphql" +#import "../../Refs/MyPages/AccountPage.graphql" +#import "../../Refs/ContentPage/ContentPage.graphql" + +fragment TertiaryLinksRef on Footer { + __typename + tertiary_links { + pageConnection { + edges { + node { + __typename + ...LoyaltyPageRef + ...ContentPageRef + ...AccountPageRef + } + } + } + } + system { + ...System + } +} diff --git a/lib/graphql/Fragments/Footer/TertiaryLinks.graphql b/lib/graphql/Fragments/Footer/TertiaryLinks.graphql new file mode 100644 index 000000000..79e3ccec0 --- /dev/null +++ b/lib/graphql/Fragments/Footer/TertiaryLinks.graphql @@ -0,0 +1,28 @@ +fragment TertiaryLinks on Footer { + tertiary_links { + open_in_new_tab + link { + href + title + } + pageConnection { + edges { + node { + __typename + ... on AccountPage { + title + url + } + ... on LoyaltyPage { + title + url + } + ... on ContentPage { + title + url + } + } + } + } + } +} diff --git a/lib/graphql/Query/Footer.graphql b/lib/graphql/Query/Footer.graphql index 211f0ef20..1551fc19a 100644 --- a/lib/graphql/Query/Footer.graphql +++ b/lib/graphql/Query/Footer.graphql @@ -2,8 +2,10 @@ #import "../Fragments/Footer/MainLinks.graphql" #import "../Fragments/Footer/SecondaryLinks.graphql" #import "../Fragments/Footer/SocialMedia.graphql" +#import "../Fragments/Footer/TertiaryLinks.graphql" #import "../Fragments/Footer/Refs/MainLinks.graphql" #import "../Fragments/Footer/Refs/SecondaryLinks.graphql" +#import "../Fragments/Footer/Refs/TertiaryLinks.graphql" #import "../Fragments/Refs/System.graphql" query GetFooter($locale: String!) { @@ -13,6 +15,7 @@ query GetFooter($locale: String!) { ...SecondaryLinks ...AppDownloads ...SocialMedia + ...TertiaryLinks } } } @@ -22,6 +25,7 @@ query GetFooterRef($locale: String!) { items { ...MainLinksRef ...SecondaryLinksRef + ...TertiaryLinksRef system { ...System } diff --git a/server/routers/contentstack/base/output.ts b/server/routers/contentstack/base/output.ts index 6e02b4cbf..6edcaae8f 100644 --- a/server/routers/contentstack/base/output.ts +++ b/server/routers/contentstack/base/output.ts @@ -317,6 +317,7 @@ export const validateFooterConfigSchema = z.object({ }) ), }), + tertiary_links: z.array(validateLinkItem), }) ), }), @@ -357,6 +358,11 @@ const validateFooterRefConfigSchema = z.object({ ), }) ), + tertiary_links: z.array( + z.object({ + pageConnection: pageConnectionRefs, + }) + ), system: z.object({ content_type_uid: z.string(), uid: z.string(), diff --git a/server/routers/contentstack/base/query.ts b/server/routers/contentstack/base/query.ts index 0d5482492..6ac685d00 100644 --- a/server/routers/contentstack/base/query.ts +++ b/server/routers/contentstack/base/query.ts @@ -351,7 +351,7 @@ export const baseQueryRouter = router({ }, } ) - console.log("responseRef", responseRef) + // There's currently no error handling/validation for the responseRef, should it be added? getFooterCounter.add(1, { lang: input.lang }) console.info( @@ -431,9 +431,10 @@ export const baseQueryRouter = router({ }) ) - console.log( - "secondaryLinks data", - JSON.stringify(secondaryLinks, null, 4) + console.log("secondaryLinks", JSON.stringify(secondaryLinks)) + + const tertiaryLinks = transformPageConnectionLinks( + validatedFooterData.tertiary_links ) return { @@ -441,6 +442,7 @@ export const baseQueryRouter = router({ appDownloads: validatedFooterData.app_downloads, secondaryLinks: secondaryLinks, socialMedia: validatedFooterData.social_media, + tertiaryLinks: tertiaryLinks, } }), }) diff --git a/server/routers/contentstack/base/utils.ts b/server/routers/contentstack/base/utils.ts index eaadabc3d..fa095dc79 100644 --- a/server/routers/contentstack/base/utils.ts +++ b/server/routers/contentstack/base/utils.ts @@ -1,7 +1,6 @@ import type { FooterLinkItem } from "./output" export function transformPageConnectionLinks(links: FooterLinkItem[]) { - console.log("linksdata", links[0].pageConnection?.edges) if (!links) return [] return links.flatMap((link) => { if (link.pageConnection?.edges.length) { diff --git a/types/components/footer/navigation.ts b/types/components/footer/navigation.ts index 9fa840f74..4da0f479d 100644 --- a/types/components/footer/navigation.ts +++ b/types/components/footer/navigation.ts @@ -1,20 +1,16 @@ -export type FooterMainNav = { - url: string - title: string -} -export type FooterMainNavProps = { - mainLinks: FooterMainNav[] -} - -export type FooterSecondaryNav = { +export type FooterLink = { isExternal: boolean openInNewTab: boolean title: string url: string } +export type FooterMainNavProps = { + mainLinks: FooterLink[] +} + type FooterSecondaryNavGroup = { title: string - links: FooterSecondaryNav[] + links: FooterLink[] } type FooterLinkWithType = { href?: @@ -42,6 +38,7 @@ export type FooterSecondaryNavProps = { export type FooterDetailsProps = { socialMedia?: FooterSocialMedia + tertiaryLinks?: FooterLink[] } export type FooterNavigationProps = FooterMainNavProps & FooterSecondaryNavProps