Skip to content

Commit

Permalink
fix: redirect page error after changing password (#627)
Browse files Browse the repository at this point in the history
  • Loading branch information
boris-w committed May 29, 2024
1 parent 89c979e commit adbe483
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ export const ChangePasswordDialog = (props: IChangePasswordDialogProps) => {
const [currentPassword, setCurrentPassword] = useState('');
const [error, setError] = useState('');

const { mutate: changePasswordMutate, isLoading } = useMutation(changePassword, {
const {
mutate: changePasswordMutate,
isLoading,
isSuccess,
} = useMutation(changePassword, {
onSuccess: () => {
toast({
title: t('settings.account.changePasswordSuccess.title'),
description: t('settings.account.changePasswordSuccess.desc'),
});
setTimeout(() => {
router.push('/auth/login', {
query: { redirect: router.asPath },
});
router.reload();
}, 2000);
},
onError: (err: HttpError) => {
Expand Down Expand Up @@ -148,7 +150,7 @@ export const ChangePasswordDialog = (props: IChangePasswordDialogProps) => {
size={'sm'}
className="w-full"
type="submit"
disabled={disableSubmitBtn}
disabled={disableSubmitBtn || isSuccess || isLoading}
onClick={handleSubmit}
>
{isLoading && <Spin className="mr-1 size-4" />}
Expand Down

0 comments on commit adbe483

Please sign in to comment.