From d6a3240d954c58b19d2aad8b9fcc3fe8d4ceb036 Mon Sep 17 00:00:00 2001 From: venthon Date: Mon, 16 Sep 2024 17:08:16 +0700 Subject: [PATCH 01/12] ES-1625 Signed-off-by: venthon --- .../src/pages/ResetPasswordPage/ResetPasswordPage.tsx | 8 ++++++-- signup-ui/src/pages/SignUpPage/SignUpPage.tsx | 2 +- signup-ui/src/pages/shared/validation.ts | 9 +++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx index 8d936f7b..91dd4981 100644 --- a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx @@ -43,7 +43,7 @@ interface ResetPasswordPageProps { } export const ResetPasswordPage = ({ settings }: ResetPasswordPageProps) => { - const { t } = useTranslation(); + const { t, i18n } = useTranslation(); const { step, criticalError } = useResetPasswordStore( useCallback( @@ -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..b9e70a05 100644 --- a/signup-ui/src/pages/SignUpPage/SignUpPage.tsx +++ b/signup-ui/src/pages/SignUpPage/SignUpPage.tsx @@ -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..fb3eb225 100644 --- a/signup-ui/src/pages/shared/validation.ts +++ b/signup-ui/src/pages/shared/validation.ts @@ -1,5 +1,6 @@ -import i18next from "i18next"; +import { TFunction } from "i18next"; import * as yup from "yup"; +import i18n from "~services/i18n.service"; import { SettingsDto } from "~typings/types"; @@ -21,20 +22,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"], }) ) From c84ee9e63c8a5893345bf06bbc7c9dc066571388 Mon Sep 17 00:00:00 2001 From: venthon Date: Tue, 17 Sep 2024 10:53:14 +0700 Subject: [PATCH 02/12] ES-1625 Signed-off-by: venthon --- signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx index 91dd4981..d494982c 100644 --- a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx @@ -43,7 +43,7 @@ interface ResetPasswordPageProps { } export const ResetPasswordPage = ({ settings }: ResetPasswordPageProps) => { - const { t, i18n } = useTranslation(); + const { t,i18n } = useTranslation(); const { step, criticalError } = useResetPasswordStore( useCallback( From ac13bfb8a101a61c163d404c5ee59044525429a0 Mon Sep 17 00:00:00 2001 From: venthon Date: Tue, 17 Sep 2024 16:19:14 +0700 Subject: [PATCH 03/12] ES-1625 Signed-off-by: venthon --- signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx index d494982c..91dd4981 100644 --- a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx @@ -43,7 +43,7 @@ interface ResetPasswordPageProps { } export const ResetPasswordPage = ({ settings }: ResetPasswordPageProps) => { - const { t,i18n } = useTranslation(); + const { t, i18n } = useTranslation(); const { step, criticalError } = useResetPasswordStore( useCallback( From 8d4f099e5a16d969dc58e61031e5b81ce6a28c2c Mon Sep 17 00:00:00 2001 From: venthon Date: Tue, 17 Sep 2024 17:23:08 +0700 Subject: [PATCH 04/12] ES-1625 Signed-off-by: venthon --- signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx | 2 +- signup-ui/src/pages/SignUpPage/SignUpPage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx index 91dd4981..a4a7f335 100644 --- a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx @@ -43,7 +43,7 @@ interface ResetPasswordPageProps { } export const ResetPasswordPage = ({ settings }: ResetPasswordPageProps) => { - const { t, i18n } = useTranslation(); + const { t } = useTranslation(); const { step, criticalError } = useResetPasswordStore( useCallback( diff --git a/signup-ui/src/pages/SignUpPage/SignUpPage.tsx b/signup-ui/src/pages/SignUpPage/SignUpPage.tsx index b9e70a05..3f8a4776 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( From fc9bc31fbfac840df11a8f305a145375ec3267a2 Mon Sep 17 00:00:00 2001 From: venthon Date: Tue, 17 Sep 2024 17:56:05 +0700 Subject: [PATCH 05/12] ES-1625 Signed-off-by: venthon --- signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx index a4a7f335..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, t), + fullname: validateFullName(settings,t), captchaToken: validateCaptchaToken(settings), }), // Step 2 - Otp From 5f64309a2bc1c4938f94115d7655340a6d1f9dfd Mon Sep 17 00:00:00 2001 From: venthon Date: Tue, 17 Sep 2024 18:04:18 +0700 Subject: [PATCH 06/12] ES-1625 Signed-off-by: venthon --- signup-ui/src/pages/SignUpPage/SignUpPage.tsx | 2 +- signup-ui/src/pages/shared/validation.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/signup-ui/src/pages/SignUpPage/SignUpPage.tsx b/signup-ui/src/pages/SignUpPage/SignUpPage.tsx index 3f8a4776..2daa4453 100644 --- a/signup-ui/src/pages/SignUpPage/SignUpPage.tsx +++ b/signup-ui/src/pages/SignUpPage/SignUpPage.tsx @@ -88,7 +88,7 @@ export const SignUpPage = ({ settings }: SignUpPageProps) => { // Step 4 - Account Setup Validation yup.object({ username: yup.string(), - fullNameInKhmer: validateFullName(settings, t), + 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 fb3eb225..83285ccf 100644 --- a/signup-ui/src/pages/shared/validation.ts +++ b/signup-ui/src/pages/shared/validation.ts @@ -22,7 +22,7 @@ export const validateCaptchaToken = (settings: any) => settings.response.configs["send-challenge.captcha.required"] && yup.string().required("captcha_token_validation"); -export const validateFullName = (settings: SettingsDto, t:TFunction<"translation", undefined>) => +export const validateFullName = (settings: SettingsDto, t:TFunction<"translation", undefined>) => yup .string() .strict(true) From d4121eae3b4b15493711d8d9f838e91163344bef Mon Sep 17 00:00:00 2001 From: venthon Date: Tue, 17 Sep 2024 18:05:57 +0700 Subject: [PATCH 07/12] ES-1625 Signed-off-by: venthon --- signup-ui/src/pages/shared/validation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signup-ui/src/pages/shared/validation.ts b/signup-ui/src/pages/shared/validation.ts index 83285ccf..fb3eb225 100644 --- a/signup-ui/src/pages/shared/validation.ts +++ b/signup-ui/src/pages/shared/validation.ts @@ -22,7 +22,7 @@ export const validateCaptchaToken = (settings: any) => settings.response.configs["send-challenge.captcha.required"] && yup.string().required("captcha_token_validation"); -export const validateFullName = (settings: SettingsDto, t:TFunction<"translation", undefined>) => +export const validateFullName = (settings: SettingsDto, t:TFunction<"translation", undefined>) => yup .string() .strict(true) From ca7bbbd5cd528cb8da495dd5556a7ecfbb6ffbc3 Mon Sep 17 00:00:00 2001 From: venthon Date: Tue, 17 Sep 2024 18:09:19 +0700 Subject: [PATCH 08/12] ES-1625 Signed-off-by: venthon --- signup-ui/src/pages/shared/validation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signup-ui/src/pages/shared/validation.ts b/signup-ui/src/pages/shared/validation.ts index fb3eb225..83285ccf 100644 --- a/signup-ui/src/pages/shared/validation.ts +++ b/signup-ui/src/pages/shared/validation.ts @@ -22,7 +22,7 @@ export const validateCaptchaToken = (settings: any) => settings.response.configs["send-challenge.captcha.required"] && yup.string().required("captcha_token_validation"); -export const validateFullName = (settings: SettingsDto, t:TFunction<"translation", undefined>) => +export const validateFullName = (settings: SettingsDto, t:TFunction<"translation", undefined>) => yup .string() .strict(true) From 881dcdc932676d0e377d3939fc37cbef4607b478 Mon Sep 17 00:00:00 2001 From: venthon Date: Tue, 17 Sep 2024 18:12:47 +0700 Subject: [PATCH 09/12] ES-1625 Signed-off-by: venthon --- signup-ui/src/pages/shared/validation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signup-ui/src/pages/shared/validation.ts b/signup-ui/src/pages/shared/validation.ts index 83285ccf..30254ab3 100644 --- a/signup-ui/src/pages/shared/validation.ts +++ b/signup-ui/src/pages/shared/validation.ts @@ -22,7 +22,7 @@ export const validateCaptchaToken = (settings: any) => settings.response.configs["send-challenge.captcha.required"] && yup.string().required("captcha_token_validation"); -export const validateFullName = (settings: SettingsDto, t:TFunction<"translation", undefined>) => +export const validateFullName = (settings: SettingsDto, t:TFunction<"translation",undefined>) => yup .string() .strict(true) From bd6e4e0daf479d716b49d263923af12bbe741419 Mon Sep 17 00:00:00 2001 From: venthon Date: Wed, 18 Sep 2024 09:14:22 +0700 Subject: [PATCH 10/12] ES-1625 Signed-off-by: venthon --- signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx | 2 +- signup-ui/src/pages/shared/validation.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx index 94782dea..a4a7f335 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,t), + fullname: validateFullName(settings, t), captchaToken: validateCaptchaToken(settings), }), // Step 2 - Otp diff --git a/signup-ui/src/pages/shared/validation.ts b/signup-ui/src/pages/shared/validation.ts index 30254ab3..fb3eb225 100644 --- a/signup-ui/src/pages/shared/validation.ts +++ b/signup-ui/src/pages/shared/validation.ts @@ -22,7 +22,7 @@ export const validateCaptchaToken = (settings: any) => settings.response.configs["send-challenge.captcha.required"] && yup.string().required("captcha_token_validation"); -export const validateFullName = (settings: SettingsDto, t:TFunction<"translation",undefined>) => +export const validateFullName = (settings: SettingsDto, t:TFunction<"translation", undefined>) => yup .string() .strict(true) From 6d9c3aa6bc37bbeb52fc49255bb8b1af7ff167ac Mon Sep 17 00:00:00 2001 From: venthon Date: Wed, 18 Sep 2024 09:17:18 +0700 Subject: [PATCH 11/12] ES-1625 Signed-off-by: venthon --- signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx | 2 +- signup-ui/src/pages/shared/validation.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx index a4a7f335..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, t), + fullname: validateFullName(settings,t), captchaToken: validateCaptchaToken(settings), }), // Step 2 - Otp diff --git a/signup-ui/src/pages/shared/validation.ts b/signup-ui/src/pages/shared/validation.ts index fb3eb225..f43bde4e 100644 --- a/signup-ui/src/pages/shared/validation.ts +++ b/signup-ui/src/pages/shared/validation.ts @@ -22,7 +22,7 @@ export const validateCaptchaToken = (settings: any) => settings.response.configs["send-challenge.captcha.required"] && yup.string().required("captcha_token_validation"); -export const validateFullName = (settings: SettingsDto, t:TFunction<"translation", undefined>) => +export const validateFullName = (settings: SettingsDto, t:TFunction< "translation", undefined >) => yup .string() .strict(true) From e92f5de12eb799c69a7758916091e1f94e64b071 Mon Sep 17 00:00:00 2001 From: venthon Date: Wed, 18 Sep 2024 10:01:19 +0700 Subject: [PATCH 12/12] ES-1625 Signed-off-by: venthon --- signup-ui/src/pages/shared/validation.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/signup-ui/src/pages/shared/validation.ts b/signup-ui/src/pages/shared/validation.ts index f43bde4e..177d026e 100644 --- a/signup-ui/src/pages/shared/validation.ts +++ b/signup-ui/src/pages/shared/validation.ts @@ -1,7 +1,5 @@ import { TFunction } from "i18next"; import * as yup from "yup"; -import i18n from "~services/i18n.service"; - import { SettingsDto } from "~typings/types"; export const validateUsername = (settings: SettingsDto) => @@ -22,7 +20,7 @@ export const validateCaptchaToken = (settings: any) => settings.response.configs["send-challenge.captcha.required"] && yup.string().required("captcha_token_validation"); -export const validateFullName = (settings: SettingsDto, t:TFunction< "translation", undefined >) => +export const validateFullName = (settings: SettingsDto, t: TFunction<"translation", undefined>) => yup .string() .strict(true)