Skip to content

Commit

Permalink
Merge pull request #350 from hngprojects/feat/116-User-Dashboard-Pass…
Browse files Browse the repository at this point in the history
…word-Settings-Page

feat(116):user-dashboard-password-settings (completed password update…
  • Loading branch information
mrcoded authored Jul 22, 2024
2 parents 2531757 + f61bb84 commit e398ca6
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions app/components/dashboard/PasswordUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,27 @@ const PasswordUpdate = () => {
handlePasswordValidation(actualValue[value_]);
}
};
const isFormValid = () => {
return (
actualValue.currentPassword.length >= 5 &&
validation.hasUppercase &&
validation.hasNumber &&
validation.hasMinLength &&
actualValue.newPassword === actualValue.confirmPassword
);
};
const handleClick = () => {
setActualValue({
currentPassword: "",
newPassword: "",
confirmPassword: "",
});
setDisplayValue({
currentPassword: "",
newPassword: "",
confirmPassword: "",
});
};
useEffect(() => {
const inputs = document.querySelectorAll<HTMLInputElement>(".psw-input");
for (const element of inputs) {
Expand Down Expand Up @@ -263,6 +284,7 @@ const PasswordUpdate = () => {
<Button
type="submit"
variant="outline"
onClick={handleClick}
size="default"
className="h-12 w-24 rounded-lg bg-transparent text-base font-bold text-black"
>
Expand All @@ -271,20 +293,10 @@ const PasswordUpdate = () => {
<AlertDialogTrigger asChild>
<Button
type="submit"
onClick={() => {
setActualValue({
currentPassword: "",
newPassword: "",
confirmPassword: "",
});
setDisplayValue({
currentPassword: "",
newPassword: "",
confirmPassword: "",
});
}}
onClick={handleClick}
variant="default"
size="default"
disabled={!isFormValid()}
className="h-12 w-44 rounded-lg bg-[rgba(249,115,22,1)] text-base font-bold text-white"
>
Update Password
Expand Down

0 comments on commit e398ca6

Please sign in to comment.