Skip to content

Commit

Permalink
Undo unintended change
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles-Pham committed Dec 18, 2024
1 parent b416129 commit dffa2b1
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions graphql/mappers/contact-us.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { cachified } from 'cachified'
import { lruCache as cache, defaultTtl as ttl } from '../../lib/cache-utils'

interface GetSchContactUsV2 {
interface GetSchContactUsV1 {
data: {
schPageV1List: {
items: Array<{
schPageV1ByPath: {
item: {
_path: string
scPageNameEn: string
scPageNameFr: string
Expand Down Expand Up @@ -61,8 +61,9 @@ interface GetSchContactUsV2 {
scLinkTextAssistiveFr?: string
scDestinationURLEn?: string
scDestinationURLFr?: string
schBetaPopUp?: boolean
}>
}>
}
}
}
}
Expand All @@ -72,10 +73,11 @@ const getCachedContent = () => {
key: `content-contact-landing-page`,
cache,
getFreshValue: async () => {
const targetUri = `${process.env.AEM_GRAPHQL_ENDPOINT}getSchContactUsV2%3BfolderName=${encodeURIComponent(process.env.AEM_GRAPHQL_FOLDER ?? '')}`
const response = await fetch(targetUri)
const response = await fetch(
`${process.env.AEM_GRAPHQL_ENDPOINT}getSchContactUsV1`,
)
if (!response.ok) return null
return (await response.json()) as GetSchContactUsV2
return (await response.json()) as GetSchContactUsV1
},
ttl,
})
Expand All @@ -102,16 +104,16 @@ export async function getContactUsContent() {
const mappedSecurity = {
en: {
breadcrumb:
response?.data.schPageV1List.items[0].scBreadcrumbParentPages.map(
response?.data.schPageV1ByPath.item.scBreadcrumbParentPages.map(
(level) => {
return {
link: level.scPageNameEn,
text: level.scTitleEn,
}
},
),
pageName: response?.data.schPageV1List.items[0].scPageNameEn,
heading: response?.data.schPageV1List.items[0].scTitleEn,
pageName: response?.data.schPageV1ByPath.item.scPageNameEn,
heading: response?.data.schPageV1ByPath.item.scTitleEn,
subHeading: introFragment?.scContentEn?.json[0].content[0].value,
links: [
{
Expand All @@ -122,6 +124,7 @@ export async function getContactUsContent() {
linkDescription: cdcpContactFragment?.scDescriptionEn?.json
? cdcpContactFragment.scDescriptionEn.json[0].content[0].value
: '',
schBetaPopup: cdcpContactFragment?.schBetaPopUp,
},
{
linkId: eiContactFragment?.scId,
Expand All @@ -131,6 +134,7 @@ export async function getContactUsContent() {
linkDescription: eiContactFragment?.scDescriptionEn?.json
? eiContactFragment.scDescriptionEn.json[0].content[0].value
: '',
schBetaPopup: eiContactFragment?.schBetaPopUp,
},
{
linkId: cppContactFragment?.scId,
Expand All @@ -140,6 +144,7 @@ export async function getContactUsContent() {
linkDescription: cppContactFragment?.scDescriptionEn?.json
? cppContactFragment.scDescriptionEn.json[0].content[0].value
: '',
schBetaPopup: cppContactFragment?.schBetaPopUp,
},
{
linkId: oasContactFragment?.scId,
Expand All @@ -149,6 +154,7 @@ export async function getContactUsContent() {
linkDescription: oasContactFragment?.scDescriptionEn?.json
? oasContactFragment.scDescriptionEn.json[0].content[0].value
: '',
schBetaPopup: oasContactFragment?.schBetaPopUp,
},
{
linkId: sinContactFragment?.scId,
Expand All @@ -158,21 +164,22 @@ export async function getContactUsContent() {
linkDescription: sinContactFragment?.scDescriptionEn?.json
? sinContactFragment.scDescriptionEn.json[0].content[0].value
: '',
schBetaPopup: sinContactFragment?.schBetaPopUp,
},
],
},
fr: {
breadcrumb:
response?.data.schPageV1List.items[0].scBreadcrumbParentPages.map(
response?.data.schPageV1ByPath.item.scBreadcrumbParentPages.map(
(level) => {
return {
link: level.scPageNameFr,
text: level.scTitleFr,
}
},
),
pageName: response?.data.schPageV1List.items[0].scPageNameFr,
heading: response?.data.schPageV1List.items[0].scTitleFr,
pageName: response?.data.schPageV1ByPath.item.scPageNameFr,
heading: response?.data.schPageV1ByPath.item.scTitleFr,
subHeading: introFragment?.scContentFr?.json[0].content[0].value,
links: [
{
Expand All @@ -183,6 +190,7 @@ export async function getContactUsContent() {
linkDescription: cdcpContactFragment?.scDescriptionFr?.json
? cdcpContactFragment.scDescriptionFr.json[0].content[0].value
: '',
schBetaPopup: cdcpContactFragment?.schBetaPopUp,
},
{
linkId: eiContactFragment?.scId,
Expand All @@ -192,6 +200,7 @@ export async function getContactUsContent() {
linkDescription: eiContactFragment?.scDescriptionFr?.json
? eiContactFragment.scDescriptionFr.json[0].content[0].value
: '',
schBetaPopup: eiContactFragment?.schBetaPopUp,
},
{
linkId: cppContactFragment?.scId,
Expand All @@ -201,6 +210,7 @@ export async function getContactUsContent() {
linkDescription: cppContactFragment?.scDescriptionFr?.json
? cppContactFragment.scDescriptionFr.json[0].content[0].value
: '',
schBetaPopup: cppContactFragment?.schBetaPopUp,
},
{
linkId: oasContactFragment?.scId,
Expand All @@ -210,6 +220,7 @@ export async function getContactUsContent() {
linkDescription: oasContactFragment?.scDescriptionFr?.json
? oasContactFragment.scDescriptionFr.json[0].content[0].value
: '',
schBetaPopup: oasContactFragment?.schBetaPopUp,
},
{
linkId: sinContactFragment?.scId,
Expand All @@ -219,16 +230,17 @@ export async function getContactUsContent() {
linkDescription: sinContactFragment?.scDescriptionFr?.json
? sinContactFragment.scDescriptionFr.json[0].content[0].value
: '',
schBetaPopup: sinContactFragment?.schBetaPopUp,
},
],
},
}
return mappedSecurity
}

const findFragmentByScId = (res: GetSchContactUsV2 | null, id: string) => {
const findFragmentByScId = (res: GetSchContactUsV1 | null, id: string) => {
return (
res?.data.schPageV1List.items[0].scFragments.find(
res?.data.schPageV1ByPath.item.scFragments.find(
({ scId }) => scId === id,
) ?? null
)
Expand Down

0 comments on commit dffa2b1

Please sign in to comment.