Use given locale input or user locale when translating updateProfile
parent
b95c884ddc
commit
c30e867147
|
@ -33,6 +33,7 @@ type UpdateProfileOptions = {
|
|||
export const updateProfileHandler = async ({ ctx, input }: UpdateProfileOptions) => {
|
||||
const { user } = ctx;
|
||||
const userMetadata = handleUserMetadata({ ctx, input });
|
||||
const locale = input.locale || user.locale;
|
||||
const data: Prisma.UserUpdateInput = {
|
||||
...input,
|
||||
metadata: userMetadata,
|
||||
|
@ -45,7 +46,7 @@ export const updateProfileHandler = async ({ ctx, input }: UpdateProfileOptions)
|
|||
|
||||
const layoutError = validateBookerLayouts(input?.metadata?.defaultBookerLayouts || null);
|
||||
if (layoutError) {
|
||||
const t = await getTranslation("en", "common");
|
||||
const t = await getTranslation(locale, "common");
|
||||
throw new TRPCError({ code: "BAD_REQUEST", message: t(layoutError) });
|
||||
}
|
||||
|
||||
|
@ -57,7 +58,8 @@ export const updateProfileHandler = async ({ ctx, input }: UpdateProfileOptions)
|
|||
const response = await checkUsername(username);
|
||||
isPremiumUsername = response.premium;
|
||||
if (!response.available) {
|
||||
throw new TRPCError({ code: "BAD_REQUEST", message: response.message });
|
||||
const t = await getTranslation(locale, "common");
|
||||
throw new TRPCError({ code: "BAD_REQUEST", message: t("username_already_taken") });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue