From 8d64c53154e93928cfa5460ca3cfe48f477ac774 Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Wed, 1 May 2024 17:34:56 +0530 Subject: [PATCH] chore: update confirm password. --- admin/app/setup/components/sign-up-form.tsx | 43 ++++++++++++++- web/components/onboarding/profile-setup.tsx | 2 +- web/pages/accounts/reset-password.tsx | 54 +++++++++---------- web/pages/accounts/set-password.tsx | 58 ++++++++++----------- 4 files changed, 96 insertions(+), 61 deletions(-) diff --git a/admin/app/setup/components/sign-up-form.tsx b/admin/app/setup/components/sign-up-form.tsx index 2b5195df6..a8bb8982e 100644 --- a/admin/app/setup/components/sign-up-form.tsx +++ b/admin/app/setup/components/sign-up-form.tsx @@ -39,6 +39,7 @@ type TFormData = { email: string; company_name: string; password: string; + confirm_password?: string; is_telemetry_enabled: boolean; }; @@ -66,6 +67,7 @@ export const InstanceSignUpForm: FC = (props) => { const [showPassword, setShowPassword] = useState(false); const [csrfToken, setCsrfToken] = useState(undefined); const [formData, setFormData] = useState(defaultFromData); + const [isPasswordInputFocused, setIsPasswordInputFocused] = useState(false); const handleFormChange = (key: keyof TFormData, value: string | boolean) => setFormData((prev) => ({ ...prev, [key]: value })); @@ -107,7 +109,11 @@ export const InstanceSignUpForm: FC = (props) => { const isButtonDisabled = useMemo( () => - formData.first_name && formData.email && formData.password && getPasswordStrength(formData.password) >= 3 + formData.first_name && + formData.email && + formData.password && + getPasswordStrength(formData.password) >= 3 && + formData.password === formData.confirm_password ? false : true, [formData] @@ -144,6 +150,7 @@ export const InstanceSignUpForm: FC = (props) => { placeholder="Wilber" value={formData.first_name} onChange={(e) => handleFormChange("first_name", e.target.value)} + autoFocus />
@@ -214,6 +221,8 @@ export const InstanceSignUpForm: FC = (props) => { value={formData.password} onChange={(e) => handleFormChange("password", e.target.value)} hasError={errorData.type && errorData.type === EErrorCodes.INVALID_PASSWORD ? true : false} + onFocus={() => setIsPasswordInputFocused(true)} + onBlur={() => setIsPasswordInputFocused(false)} /> {showPassword ? (
+ +
+ +
+ handleFormChange("confirm_password", e.target.value)} + placeholder="Confirm password" + className="h-[46px] w-full border border-onboarding-border-100 !bg-onboarding-background-200 pr-12 placeholder:text-onboarding-text-400" + /> + {showPassword ? ( + setShowPassword(false)} + /> + ) : ( + setShowPassword(true)} + /> + )} +
+ {!!formData.confirm_password && formData.password !== formData.confirm_password && ( + Passwords don{"'"}t match + )}
diff --git a/web/components/onboarding/profile-setup.tsx b/web/components/onboarding/profile-setup.tsx index c8f25e03d..c96651986 100644 --- a/web/components/onboarding/profile-setup.tsx +++ b/web/components/onboarding/profile-setup.tsx @@ -437,7 +437,7 @@ export const ProfileSetup: React.FC = observer((props) => { {errors.password && {errors.password.message}}
)} - {!isPasswordAlreadySetup && password && getPasswordStrength(password) >= 3 && ( + {!isPasswordAlreadySetup && (
{isPasswordInputFocused && } - {getPasswordStrength(resetFormData.password) >= 3 && ( -
- -
- handleFormChange("confirm_password", e.target.value)} - placeholder="Confirm password" - className="h-[46px] w-full border border-onboarding-border-100 !bg-onboarding-background-200 pr-12 placeholder:text-onboarding-text-400" +
+ +
+ handleFormChange("confirm_password", e.target.value)} + placeholder="Confirm password" + className="h-[46px] w-full border border-onboarding-border-100 !bg-onboarding-background-200 pr-12 placeholder:text-onboarding-text-400" + /> + {showPassword ? ( + setShowPassword(false)} + /> + ) : ( + setShowPassword(true)} /> - {showPassword ? ( - setShowPassword(false)} - /> - ) : ( - setShowPassword(true)} - /> - )} -
- {!!resetFormData.confirm_password && resetFormData.password !== resetFormData.confirm_password && ( - Passwords don{"'"}t match )}
- )} + {!!resetFormData.confirm_password && resetFormData.password !== resetFormData.confirm_password && ( + Passwords don{"'"}t match + )} +
diff --git a/web/pages/accounts/set-password.tsx b/web/pages/accounts/set-password.tsx index 0e42b7110..8fc7136e8 100644 --- a/web/pages/accounts/set-password.tsx +++ b/web/pages/accounts/set-password.tsx @@ -183,38 +183,36 @@ const SetPasswordPage: NextPageWithLayout = observer(() => {
{isPasswordInputFocused && } - {getPasswordStrength(passwordFormData.password) >= 3 && ( -
- -
- handleFormChange("confirm_password", e.target.value)} - placeholder="Confirm password" - className="h-[46px] w-full border border-onboarding-border-100 !bg-onboarding-background-200 pr-12 placeholder:text-onboarding-text-400" +
+ +
+ handleFormChange("confirm_password", e.target.value)} + placeholder="Confirm password" + className="h-[46px] w-full border border-onboarding-border-100 !bg-onboarding-background-200 pr-12 placeholder:text-onboarding-text-400" + /> + {showPassword ? ( + setShowPassword(false)} /> - {showPassword ? ( - setShowPassword(false)} - /> - ) : ( - setShowPassword(true)} - /> - )} -
- {!!passwordFormData.confirm_password && - passwordFormData.password !== passwordFormData.confirm_password && ( - Passwords don{"'"}t match - )} + ) : ( + setShowPassword(true)} + /> + )}
- )} + {!!passwordFormData.confirm_password && + passwordFormData.password !== passwordFormData.confirm_password && ( + Passwords don{"'"}t match + )} +