fix: trpc endpoint for footer data
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { GetContactConfig } from "@/lib/graphql/Query/ContactConfig.graphql"
|
||||
import { GetCurrentFooter } from "@/lib/graphql/Query/CurrentFooter.graphql"
|
||||
import {
|
||||
GetCurrentHeader,
|
||||
GetCurrentHeaderRef,
|
||||
@@ -11,10 +12,12 @@ import { generateTag } from "@/utils/generateTag"
|
||||
|
||||
import {
|
||||
type ContactConfigData,
|
||||
FooterDataRaw,
|
||||
HeaderData,
|
||||
HeaderDataRaw,
|
||||
HeaderRefDataRaw,
|
||||
validateContactConfigSchema,
|
||||
validateFooterConfigSchema,
|
||||
validateHeaderConfigSchema,
|
||||
} from "./output"
|
||||
|
||||
@@ -81,4 +84,25 @@ export const configQueryRouter = router({
|
||||
logo,
|
||||
} as HeaderData
|
||||
}),
|
||||
footer: contentstackProcedure.query(async ({ ctx }) => {
|
||||
const response = await request<FooterDataRaw>(
|
||||
GetCurrentFooter,
|
||||
{
|
||||
locale: ctx.lang,
|
||||
},
|
||||
{
|
||||
next: { tags: [`footer-${ctx.lang}`] },
|
||||
}
|
||||
)
|
||||
|
||||
const validatedFooterConfig = validateFooterConfigSchema.safeParse(
|
||||
response.data
|
||||
)
|
||||
|
||||
if (!validatedFooterConfig.success) {
|
||||
throw internalServerError(validatedFooterConfig.error)
|
||||
}
|
||||
|
||||
return validatedFooterConfig.data.all_current_footer.items[0]
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user