diff --git a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx index 8d936f7b..94782dea 100644 --- a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx @@ -60,7 +60,7 @@ export const ResetPasswordPage = ({ settings }: ResetPasswordPageProps) => { // Step 1 - UserInfo yup.object({ username: validateUsername(settings), - fullname: validateFullName(settings), + fullname: validateFullName(settings,t), captchaToken: validateCaptchaToken(settings), }), // Step 2 - Otp @@ -128,6 +128,10 @@ export const ResetPasswordPage = ({ settings }: ResetPasswordPageProps) => { }; }, [step, criticalError, getValues()]); + // useEffect(() => { + // methods.trigger(); + // }, [i18n.language, methods]); + const getResetPasswordContent = (step: ResetPasswordStep) => { switch (step) { case ResetPasswordStep.UserInfo: diff --git a/signup-ui/src/pages/SignUpPage/SignUpPage.tsx b/signup-ui/src/pages/SignUpPage/SignUpPage.tsx index ca7f5e44..2daa4453 100644 --- a/signup-ui/src/pages/SignUpPage/SignUpPage.tsx +++ b/signup-ui/src/pages/SignUpPage/SignUpPage.tsx @@ -60,7 +60,7 @@ interface SignUpPageProps { } export const SignUpPage = ({ settings }: SignUpPageProps) => { - const { t } = useTranslation(); + const { t, i18n} = useTranslation(); const { step, criticalError } = useSignUpStore( useCallback( @@ -88,7 +88,7 @@ export const SignUpPage = ({ settings }: SignUpPageProps) => { // Step 4 - Account Setup Validation yup.object({ username: yup.string(), - fullNameInKhmer: validateFullName(settings), + fullNameInKhmer: validateFullName(settings,t), password: validatePassword(settings), confirmPassword: validateConfirmPassword("password", settings, true), consent: yup.bool().oneOf([true], t("terms_and_conditions_validation")), diff --git a/signup-ui/src/pages/shared/validation.ts b/signup-ui/src/pages/shared/validation.ts index 164ac205..177d026e 100644 --- a/signup-ui/src/pages/shared/validation.ts +++ b/signup-ui/src/pages/shared/validation.ts @@ -1,6 +1,5 @@ -import i18next from "i18next"; +import { TFunction } from "i18next"; import * as yup from "yup"; - import { SettingsDto } from "~typings/types"; export const validateUsername = (settings: SettingsDto) => @@ -21,20 +20,20 @@ export const validateCaptchaToken = (settings: any) => settings.response.configs["send-challenge.captcha.required"] && yup.string().required("captcha_token_validation"); -export const validateFullName = (settings: SettingsDto) => +export const validateFullName = (settings: SettingsDto, t: TFunction<"translation", undefined>) => yup .string() .strict(true) .trim("full_name_all_spaces_validation") .min( settings.response.configs["fullname.length.min"], - i18next.t("full_name_min_validation", { + t("full_name_min_validation", { minLength: settings.response.configs["fullname.length.min"], }) ) .max( settings.response.configs["fullname.length.max"], - i18next.t("full_name_max_validation", { + t("full_name_max_validation", { maxLength: settings.response.configs["fullname.length.max"], }) )