Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES 1625 #356

Merged
merged 12 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions signup-ui/src/pages/SignUpPage/SignUpPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ interface SignUpPageProps {
}

export const SignUpPage = ({ settings }: SignUpPageProps) => {
const { t } = useTranslation();
const { t, i18n} = useTranslation();

const { step, criticalError } = useSignUpStore(
useCallback(
Expand Down Expand Up @@ -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")),
Expand Down
9 changes: 4 additions & 5 deletions signup-ui/src/pages/shared/validation.ts
Original file line number Diff line number Diff line change
@@ -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) =>
Expand All @@ -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"],
})
)
Expand Down
Loading