Skip to content

Commit

Permalink
fix: change password
Browse files Browse the repository at this point in the history
  • Loading branch information
HollaG committed Nov 14, 2024
1 parent 2709df2 commit bffd33a
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions peer-prep/src/pages/ChangePassword/ChangePasswordPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function getStrength(password: string) {

export default function ChangePasswordPage() {
const navigate = useNavigate();

const [currentPassword, setCurrentPassword] = useState("");
const [newPassword, setNewPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
Expand All @@ -78,7 +78,7 @@ export default function ChangePasswordPage() {
requirement.re.test(newPassword)
);

const bars = Array(4)
const bars = Array(4)
.fill(0)
.map((_, index) => (
<Progress
Expand Down Expand Up @@ -117,7 +117,7 @@ const bars = Array(4)
};

// Call the backend using the fetchData hook
const response = await fetchData<ServerResponse<{user: User}>>(
const response = await fetchData<ServerResponse<{ user: User }>>(
"/user-service/users/changePassword",
SERVICE.USER,
{
Expand All @@ -126,7 +126,10 @@ const bars = Array(4)
"Content-Type": "application/json",
},
body: JSON.stringify(requestBody),
}
},
false,
false,
true
);

// Show success message if password change is successful
Expand Down Expand Up @@ -167,7 +170,6 @@ const bars = Array(4)
}
};


return (
<Center>
<form
Expand All @@ -189,7 +191,7 @@ const bars = Array(4)
onChange={(event) => setCurrentPassword(event.currentTarget.value)}
mt="md"
size="md"
style={{ width: '500px' }}
style={{ width: "500px" }}
/>

<PasswordInput
Expand All @@ -200,19 +202,19 @@ const bars = Array(4)
size="md"
onChange={(event) => setNewPassword(event.currentTarget.value)}
value={newPassword}
style={{ width: '500px' }}
style={{ width: "500px" }}
visible={newPasswordVisible}
onVisibilityChange={toggle}
/>

<Box
mt="xs"
style={{
display: 'flex',
gap: '5px',
width: '100%',
overflow: 'visible',
maxWidth: '500px',
display: "flex",
gap: "5px",
width: "100%",
overflow: "visible",
maxWidth: "500px",
}}
>
{bars}
Expand All @@ -228,10 +230,12 @@ const bars = Array(4)
onChange={(event) => setConfirmPassword(event.currentTarget.value)}
mt="md"
size="md"
style={{ width: '500px' }}
style={{ width: "500px" }}
visible={newPasswordVisible}
onVisibilityChange={toggle}
error={confirmPassword.length > 0 && confirmPassword !== newPassword}
error={
confirmPassword.length > 0 && confirmPassword !== newPassword
}
/>

<Button
Expand All @@ -247,4 +251,4 @@ const bars = Array(4)
</form>
</Center>
);
}
}

0 comments on commit bffd33a

Please sign in to comment.