feat(SW-187): Added tertiary links data
This commit is contained in:
@@ -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 (
|
||||
<section className={styles.details}>
|
||||
<div className={styles.topContainer}>
|
||||
@@ -68,18 +69,21 @@ export default async function FooterDetails({
|
||||
</div>
|
||||
<div className={styles.navigationContainer}>
|
||||
<nav className={styles.navigation}>
|
||||
{tertiaryLinks.map((link) => (
|
||||
<Footnote asChild textTransform="uppercase" key={link.id}>
|
||||
<Link
|
||||
className={styles.link}
|
||||
color="peach50"
|
||||
href={link.href}
|
||||
target="_blank"
|
||||
>
|
||||
{link.title}
|
||||
</Link>
|
||||
</Footnote>
|
||||
))}
|
||||
{tertiaryLinks?.map(
|
||||
(link) =>
|
||||
link.url && (
|
||||
<Footnote asChild textTransform="uppercase" key={link.title}>
|
||||
<Link
|
||||
className={styles.link}
|
||||
color="peach50"
|
||||
href={link.url}
|
||||
target="_blank"
|
||||
>
|
||||
{link.title}
|
||||
</Link>
|
||||
</Footnote>
|
||||
)
|
||||
)}
|
||||
</nav>
|
||||
<LanguageSwitcher type="desktopFooter" urls={languageSwitcher.urls} />
|
||||
</div>
|
||||
|
||||
@@ -19,7 +19,10 @@ export default async function Footer() {
|
||||
secondaryLinks={footerData.secondaryLinks}
|
||||
appDownloads={footerData.appDownloads}
|
||||
/>
|
||||
<FooterDetails socialMedia={footerData.socialMedia} />
|
||||
<FooterDetails
|
||||
socialMedia={footerData.socialMedia}
|
||||
tertiaryLinks={footerData.tertiaryLinks}
|
||||
/>
|
||||
</footer>
|
||||
)
|
||||
}
|
||||
|
||||
22
lib/graphql/Fragments/Footer/Refs/TertiaryLinks.graphql
Normal file
22
lib/graphql/Fragments/Footer/Refs/TertiaryLinks.graphql
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
28
lib/graphql/Fragments/Footer/TertiaryLinks.graphql
Normal file
28
lib/graphql/Fragments/Footer/TertiaryLinks.graphql
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user