From bffd33ad3df6368432b19862bc652c46189c1672 Mon Sep 17 00:00:00 2001 From: hollag Date: Thu, 14 Nov 2024 09:40:33 +0800 Subject: [PATCH] fix: change password --- .../ChangePassword/ChangePasswordPage.tsx | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/peer-prep/src/pages/ChangePassword/ChangePasswordPage.tsx b/peer-prep/src/pages/ChangePassword/ChangePasswordPage.tsx index 25015ae813..4b90a34037 100644 --- a/peer-prep/src/pages/ChangePassword/ChangePasswordPage.tsx +++ b/peer-prep/src/pages/ChangePassword/ChangePasswordPage.tsx @@ -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(""); @@ -78,7 +78,7 @@ export default function ChangePasswordPage() { requirement.re.test(newPassword) ); -const bars = Array(4) + const bars = Array(4) .fill(0) .map((_, index) => ( >( + const response = await fetchData>( "/user-service/users/changePassword", SERVICE.USER, { @@ -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 @@ -167,7 +170,6 @@ const bars = Array(4) } }; - return (
setCurrentPassword(event.currentTarget.value)} mt="md" size="md" - style={{ width: '500px' }} + style={{ width: "500px" }} /> setNewPassword(event.currentTarget.value)} value={newPassword} - style={{ width: '500px' }} + style={{ width: "500px" }} visible={newPasswordVisible} onVisibilityChange={toggle} /> @@ -208,11 +210,11 @@ const bars = Array(4) {bars} @@ -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 + } />
); -} \ No newline at end of file +}