feat(SW-543): update requests
This commit is contained in:
@@ -14,6 +14,7 @@ fragment ContactFields on ContactFields {
|
|||||||
display_text
|
display_text
|
||||||
contact_field
|
contact_field
|
||||||
footnote
|
footnote
|
||||||
|
select_test
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment JoinLoyaltyContactSidebar_ContentPage on ContentPageSidebarJoinLoyaltyContact {
|
fragment JoinLoyaltyContactSidebar_ContentPage on ContentPageSidebarJoinLoyaltyContact {
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ export type ContactFields = {
|
|||||||
display_text: string | null
|
display_text: string | null
|
||||||
contact_field: string
|
contact_field: string
|
||||||
footnote: string | null
|
footnote: string | null
|
||||||
|
selectTest: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const validateCurrentHeaderConfigSchema = z
|
export const validateCurrentHeaderConfigSchema = z
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { cache } from "react"
|
import { cache } from "react"
|
||||||
|
|
||||||
import { Lang } from "@/constants/languages"
|
|
||||||
import { GetContactConfig } from "@/lib/graphql/Query/ContactConfig.graphql"
|
import { GetContactConfig } from "@/lib/graphql/Query/ContactConfig.graphql"
|
||||||
import {
|
import {
|
||||||
GetCurrentFooter,
|
GetCurrentFooter,
|
||||||
@@ -30,9 +29,9 @@ import {
|
|||||||
import { langInput } from "./input"
|
import { langInput } from "./input"
|
||||||
import {
|
import {
|
||||||
type ContactConfigData,
|
type ContactConfigData,
|
||||||
CurrentFooterDataRaw,
|
type CurrentFooterDataRaw,
|
||||||
CurrentFooterRefDataRaw,
|
type CurrentFooterRefDataRaw,
|
||||||
CurrentHeaderRefDataRaw,
|
type CurrentHeaderRefDataRaw,
|
||||||
type GetCurrentHeaderData,
|
type GetCurrentHeaderData,
|
||||||
headerRefsSchema,
|
headerRefsSchema,
|
||||||
headerSchema,
|
headerSchema,
|
||||||
@@ -94,8 +93,9 @@ import type {
|
|||||||
GetSiteConfigData,
|
GetSiteConfigData,
|
||||||
GetSiteConfigRefData,
|
GetSiteConfigRefData,
|
||||||
} from "@/types/trpc/routers/contentstack/siteConfig"
|
} from "@/types/trpc/routers/contentstack/siteConfig"
|
||||||
|
import type { Lang } from "@/constants/languages"
|
||||||
|
|
||||||
const getContactConfig = cache(async (lang: Lang) => {
|
export 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,6 +6,7 @@ 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,
|
||||||
@@ -39,41 +40,46 @@ export const contentPageQueryRouter = router({
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
const contentPageRequest = await batchRequest<GetContentPageSchema>([
|
const [contentPageRequest, contactConfig] = await Promise.all([
|
||||||
{
|
batchRequest<GetContentPageSchema>([
|
||||||
document: GetContentPage,
|
{
|
||||||
variables: { locale: lang, uid },
|
document: GetContentPage,
|
||||||
options: {
|
variables: { locale: lang, uid },
|
||||||
cache: "force-cache",
|
options: {
|
||||||
next: {
|
cache: "force-cache",
|
||||||
tags,
|
next: {
|
||||||
|
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(
|
||||||
@@ -95,9 +101,14 @@ 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,6 +14,7 @@ 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"
|
||||||
|
|
||||||
@@ -129,14 +130,13 @@ export const loyaltyPageQueryRouter = router({
|
|||||||
query: metricsVariables,
|
query: metricsVariables,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
const response = await request<GetLoyaltyPageSchema>(
|
const [response, contactConfig] = await Promise.all([
|
||||||
GetLoyaltyPage,
|
request<GetLoyaltyPageSchema>(GetLoyaltyPage, variables, {
|
||||||
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,6 +172,8 @@ 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 = {
|
||||||
@@ -191,10 +193,15 @@ 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,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export const contactSchema = z.object({
|
|||||||
contact_field: z.string(),
|
contact_field: z.string(),
|
||||||
display_text: z.string().optional().nullable().default(null),
|
display_text: z.string().optional().nullable().default(null),
|
||||||
footnote: z.string().optional().nullable().default(null),
|
footnote: z.string().optional().nullable().default(null),
|
||||||
|
select_test: z.string(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.transform((data) => {
|
.transform((data) => {
|
||||||
@@ -32,6 +33,7 @@ export const contactSchema = z.object({
|
|||||||
contact_field: data.contact.contact_field,
|
contact_field: data.contact.contact_field,
|
||||||
display_text: data.contact.display_text,
|
display_text: data.contact.display_text,
|
||||||
footnote: data.contact.footnote,
|
footnote: data.contact.footnote,
|
||||||
|
selectTest: data.contact.select_test,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { z } from "zod"
|
import type { z } from "zod"
|
||||||
|
|
||||||
import { joinLoyaltyContactSidebarSchema } from "@/server/routers/contentstack/loyaltyPage/output"
|
import type { joinLoyaltyContactSidebarSchema } from "@/server/routers/contentstack/loyaltyPage/output"
|
||||||
import { contactSchema } from "@/server/routers/contentstack/schemas/sidebar/joinLoyaltyContact"
|
import type { contactSchema } from "@/server/routers/contentstack/schemas/sidebar/joinLoyaltyContact"
|
||||||
|
|
||||||
export interface JoinLoyaltyContact
|
export interface JoinLoyaltyContact
|
||||||
extends z.output<typeof joinLoyaltyContactSidebarSchema> {}
|
extends z.output<typeof joinLoyaltyContactSidebarSchema> {}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import type { z } from "zod"
|
||||||
|
|
||||||
import {
|
import type {
|
||||||
alertSchema,
|
alertSchema,
|
||||||
siteConfigRefSchema,
|
siteConfigRefSchema,
|
||||||
siteConfigSchema,
|
siteConfigSchema,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {
|
import type {
|
||||||
ContactConfig,
|
ContactConfig,
|
||||||
ContactFieldGroups,
|
ContactFieldGroups,
|
||||||
} from "@/server/routers/contentstack/base/output"
|
} from "@/server/routers/contentstack/base/output"
|
||||||
|
|||||||
Reference in New Issue
Block a user