* move setLang() to a root layout

* fix: findLang only returns acceptable languages
* fix: fallback to use header x-lang if we haven't setLang yet
* fix: languageSchema, allow uppercase

Approved-by: Linus Flood
This commit is contained in:
Joakim Jäderberg
2025-02-19 09:06:37 +00:00
parent d27163a915
commit 873183ec2f
45 changed files with 159 additions and 117 deletions
@@ -1,7 +1,7 @@
import { z } from "zod"
import { MembershipLevelEnum } from "@/constants/membershipLevels"
import { Lang } from "@/constants/languages"
import { MembershipLevelEnum } from "@/constants/membershipLevels"
export const loyaltyLevelInput = z.object({
level: z.nativeEnum(MembershipLevelEnum),
@@ -33,7 +33,7 @@ const outputSchema = z.object({
export const verifyOtp = protectedProcedure
.input(inputSchema)
.output(outputSchema)
.mutation(async function ({ ctx, input }) {
.mutation(async function ({ input }) {
const sasAuthToken = getSasToken()
if (!sasAuthToken) {
+1
View File
@@ -57,6 +57,7 @@ export const contentstackBaseProcedure = baseProcedure.use(
if (!opts.ctx.lang) {
// When fetching data client side with TRPC we don't pass through middlewares and therefore do not get the lang through headers
// We can then pass lang as an input in the request and set it to the context in the procedure
const input = await opts.getRawInput()
const parsedInput = langInput.safeParse(input)
if (!parsedInput.success) {