feat(SW-543): restore requests
This commit is contained in:
@@ -17,6 +17,7 @@ export default async function ContactRow({ contact }: ContactRowProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const val = getValueFromContactConfig(contact.contact_field, data)
|
const val = getValueFromContactConfig(contact.contact_field, data)
|
||||||
|
const test = getValueFromContactConfig(contact.selectTest, data)
|
||||||
|
|
||||||
if (!val) {
|
if (!val) {
|
||||||
return null
|
return null
|
||||||
@@ -51,7 +52,7 @@ export default async function ContactRow({ contact }: ContactRowProps) {
|
|||||||
{Icon ? <Icon width="20" height="20" color="burgundy" /> : null}
|
{Icon ? <Icon width="20" height="20" color="burgundy" /> : null}
|
||||||
{val}
|
{val}
|
||||||
</Link>
|
</Link>
|
||||||
<Footnote color="burgundy">{contact.footnote}</Footnote>
|
<Footnote color="burgundy">{test}</Footnote>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ import type {
|
|||||||
} from "@/types/trpc/routers/contentstack/siteConfig"
|
} from "@/types/trpc/routers/contentstack/siteConfig"
|
||||||
import type { Lang } from "@/constants/languages"
|
import type { Lang } from "@/constants/languages"
|
||||||
|
|
||||||
export const getContactConfig = cache(async (lang: Lang) => {
|
const getContactConfig = cache(async (lang: Lang) => {
|
||||||
getContactConfigCounter.add(1, { lang })
|
getContactConfigCounter.add(1, { lang })
|
||||||
console.info(
|
console.info(
|
||||||
"contentstack.contactConfig start",
|
"contentstack.contactConfig start",
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
} from "@/lib/graphql/Query/ContentPage/ContentPage.graphql"
|
} from "@/lib/graphql/Query/ContentPage/ContentPage.graphql"
|
||||||
import { contentstackExtendedProcedureUID, router } from "@/server/trpc"
|
import { contentstackExtendedProcedureUID, router } from "@/server/trpc"
|
||||||
|
|
||||||
import { getContactConfig } from "../base/query"
|
|
||||||
import { contentPageSchema } from "./output"
|
import { contentPageSchema } from "./output"
|
||||||
import {
|
import {
|
||||||
createChannel,
|
createChannel,
|
||||||
@@ -40,46 +39,41 @@ export const contentPageQueryRouter = router({
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
const [contentPageRequest, contactConfig] = await Promise.all([
|
const contentPageRequest = await batchRequest<GetContentPageSchema>([
|
||||||
batchRequest<GetContentPageSchema>([
|
{
|
||||||
{
|
document: GetContentPage,
|
||||||
document: GetContentPage,
|
variables: { locale: lang, uid },
|
||||||
variables: { locale: lang, uid },
|
options: {
|
||||||
options: {
|
cache: "force-cache",
|
||||||
cache: "force-cache",
|
next: {
|
||||||
next: {
|
tags,
|
||||||
tags,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
document: GetContentPageBlocksBatch1,
|
document: GetContentPageBlocksBatch1,
|
||||||
variables: { locale: lang, uid },
|
variables: { locale: lang, uid },
|
||||||
options: {
|
options: {
|
||||||
cache: "force-cache",
|
cache: "force-cache",
|
||||||
next: {
|
next: {
|
||||||
tags,
|
tags,
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
document: GetContentPageBlocksBatch2,
|
document: GetContentPageBlocksBatch2,
|
||||||
variables: { locale: lang, uid },
|
variables: { locale: lang, uid },
|
||||||
options: {
|
options: {
|
||||||
cache: "force-cache",
|
cache: "force-cache",
|
||||||
next: {
|
next: {
|
||||||
tags,
|
tags,
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]),
|
},
|
||||||
getContactConfig(lang),
|
|
||||||
])
|
])
|
||||||
|
|
||||||
console.log("Content page log", contentPageRequest, contactConfig)
|
|
||||||
|
|
||||||
const contentPage = contentPageSchema.safeParse(contentPageRequest.data)
|
const contentPage = contentPageSchema.safeParse(contentPageRequest.data)
|
||||||
if (!contentPage.success) {
|
if (!contentPage.success) {
|
||||||
console.error(
|
console.error(
|
||||||
@@ -101,14 +95,9 @@ export const contentPageQueryRouter = router({
|
|||||||
siteVersion: "new-web",
|
siteVersion: "new-web",
|
||||||
}
|
}
|
||||||
|
|
||||||
const footnote = contactConfig?.phone.footnote
|
|
||||||
? contactConfig.phone.footnote
|
|
||||||
: null
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
contentPage: contentPage.data.content_page,
|
contentPage: contentPage.data.content_page,
|
||||||
tracking,
|
tracking,
|
||||||
footnote,
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import {
|
|||||||
generateTagsFromSystem,
|
generateTagsFromSystem,
|
||||||
} from "@/utils/generateTag"
|
} from "@/utils/generateTag"
|
||||||
|
|
||||||
import { getContactConfig } from "../base/query"
|
|
||||||
import { loyaltyPageRefsSchema, loyaltyPageSchema } from "./output"
|
import { loyaltyPageRefsSchema, loyaltyPageSchema } from "./output"
|
||||||
import { getConnections } from "./utils"
|
import { getConnections } from "./utils"
|
||||||
|
|
||||||
@@ -130,13 +129,14 @@ export const loyaltyPageQueryRouter = router({
|
|||||||
query: metricsVariables,
|
query: metricsVariables,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
const [response, contactConfig] = await Promise.all([
|
const response = await request<GetLoyaltyPageSchema>(
|
||||||
request<GetLoyaltyPageSchema>(GetLoyaltyPage, variables, {
|
GetLoyaltyPage,
|
||||||
|
variables,
|
||||||
|
{
|
||||||
cache: "force-cache",
|
cache: "force-cache",
|
||||||
next: { tags },
|
next: { tags },
|
||||||
}),
|
}
|
||||||
getContactConfig(lang),
|
)
|
||||||
])
|
|
||||||
|
|
||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
const notFoundError = notFound(response)
|
const notFoundError = notFound(response)
|
||||||
@@ -172,8 +172,6 @@ export const loyaltyPageQueryRouter = router({
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Loyalty page log: ", response, contactConfig)
|
|
||||||
|
|
||||||
const loyaltyPage = validatedLoyaltyPage.data.loyalty_page
|
const loyaltyPage = validatedLoyaltyPage.data.loyalty_page
|
||||||
|
|
||||||
const loyaltyTrackingData: TrackingSDKPageData = {
|
const loyaltyTrackingData: TrackingSDKPageData = {
|
||||||
@@ -193,15 +191,10 @@ export const loyaltyPageQueryRouter = router({
|
|||||||
JSON.stringify({ query: metricsVariables })
|
JSON.stringify({ query: metricsVariables })
|
||||||
)
|
)
|
||||||
|
|
||||||
const footnote = contactConfig?.phone.footnote
|
|
||||||
? contactConfig.phone.footnote
|
|
||||||
: null
|
|
||||||
|
|
||||||
// Assert LoyaltyPage type to get correct typings for RTE fields
|
// Assert LoyaltyPage type to get correct typings for RTE fields
|
||||||
return {
|
return {
|
||||||
loyaltyPage,
|
loyaltyPage,
|
||||||
tracking: loyaltyTrackingData,
|
tracking: loyaltyTrackingData,
|
||||||
footnote,
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user