From f7b92931a985e9ec334c1abc9886c72c01d6bbfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Dere=C5=BEi=C4=87?= Date: Sat, 17 Feb 2024 10:17:17 +0100 Subject: [PATCH] i18n: fixing form validaton messages --- app/lib/actions/billActions.ts | 10 +++++----- app/lib/actions/locationActions.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/lib/actions/billActions.ts b/app/lib/actions/billActions.ts index 97820ff..0db48ab 100644 --- a/app/lib/actions/billActions.ts +++ b/app/lib/actions/billActions.ts @@ -26,7 +26,7 @@ export type State = { */ const FormSchema = (t:IntlTemplateFn) => z.object({ _id: z.string(), - billName: z.coerce.string().min(1, t("validation.bill-name-required")), + billName: z.coerce.string().min(1, t("bill-name-required")), billNotes: z.string(), payedAmount: z.string().nullable().transform((val, ctx) => { @@ -39,7 +39,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({ if (isNaN(parsed)) { ctx.addIssue({ code: z.ZodIssueCode.custom, - message: t("validation.not-a-number"), + message: t("not-a-number"), }); // This is a special symbol you can use to @@ -52,7 +52,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({ if (parsed < 0) { ctx.addIssue({ code: z.ZodIssueCode.custom, - message: t("validation.negative-number") + message: t("negative-number") }); // This is a special symbol you can use to @@ -115,7 +115,7 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI const { id: userId } = user; - const t = await getTranslations("bill-edit-form"); + const t = await getTranslations("bill-edit-form.validation"); // FormSchema const validatedFields = FormSchema(t) @@ -131,7 +131,7 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI console.log("updateBill.validation-error"); return({ errors: validatedFields.error.flatten().fieldErrors, - message: t("validation.form-error-message"), + message: t("form-error-message"), }); } diff --git a/app/lib/actions/locationActions.ts b/app/lib/actions/locationActions.ts index b662c6a..635acfb 100644 --- a/app/lib/actions/locationActions.ts +++ b/app/lib/actions/locationActions.ts @@ -25,7 +25,7 @@ export type State = { */ const FormSchema = (t:IntlTemplateFn) => z.object({ _id: z.string(), - locationName: z.coerce.string().min(1, t("validation.location-name-required")), + locationName: z.coerce.string().min(1, t("location-name-required")), locationNotes: z.string(), }) // dont include the _id field in the response @@ -42,7 +42,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat noStore(); - const t = await getTranslations("location-edit-form"); + const t = await getTranslations("location-edit-form.validation"); const validatedFields = FormSchema(t).safeParse({ locationName: formData.get('locationName'),