feat: add JoinLoyalty component
This commit is contained in:
5
server/routers/contentstack/contactConfig/index.ts
Normal file
5
server/routers/contentstack/contactConfig/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { mergeRouters } from "@/server/trpc"
|
||||
|
||||
import { contactConfigQueryRouter } from "./query"
|
||||
|
||||
export const contactConfigRouter = mergeRouters(contactConfigQueryRouter)
|
||||
32
server/routers/contentstack/contactConfig/query.ts
Normal file
32
server/routers/contentstack/contactConfig/query.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import { badRequestError } from "@/server/errors/trpc"
|
||||
import { publicProcedure, router } from "@/server/trpc"
|
||||
import { request } from "@/lib/graphql/request"
|
||||
import { Lang } from "@/constants/languages"
|
||||
|
||||
import GetContactConfig from "@/lib/graphql/Query/ContactConfig.graphql"
|
||||
|
||||
import type { GetContactConfigData } from "@/types/requests/contactConfig"
|
||||
|
||||
export const contactConfigQueryRouter = router({
|
||||
get: publicProcedure
|
||||
.input(z.object({ lang: z.nativeEnum(Lang) }))
|
||||
.query(async ({ input }) => {
|
||||
const contactConfig = await request<GetContactConfigData>(
|
||||
GetContactConfig,
|
||||
{
|
||||
locale: input.lang,
|
||||
},
|
||||
{
|
||||
tags: [`contact-config-${input.lang}`],
|
||||
}
|
||||
)
|
||||
|
||||
if (contactConfig.data && contactConfig.data.all_contact_config.total) {
|
||||
return contactConfig.data.all_contact_config.items[0]
|
||||
}
|
||||
|
||||
throw badRequestError()
|
||||
}),
|
||||
})
|
||||
@@ -2,8 +2,10 @@ import { router } from "@/server/trpc"
|
||||
|
||||
import { breadcrumbsRouter } from "./breadcrumbs"
|
||||
import { loyaltyPageRouter } from "./loyaltyPage"
|
||||
import { contactConfigRouter } from "./contactConfig"
|
||||
|
||||
export const contentstackRouter = router({
|
||||
breadcrumbs: breadcrumbsRouter,
|
||||
loyaltyPage: loyaltyPageRouter,
|
||||
contactConfig: contactConfigRouter,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user