From dddedc5bc2569620cd16efe10493ea3cd42c0483 Mon Sep 17 00:00:00 2001 From: Henil Panchal Date: Sun, 25 Jun 2023 10:32:11 +0530 Subject: [PATCH] fix: add loading and notification --- registry/src/pages/account.js | 14 ++++++-------- registry/src/store/actions/accountActions.js | 1 + registry/src/store/reducers/accountReducer.js | 4 ++++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/registry/src/pages/account.js b/registry/src/pages/account.js index 2be9545a..8d7a27df 100644 --- a/registry/src/pages/account.js +++ b/registry/src/pages/account.js @@ -40,6 +40,9 @@ const Account = () => { const isLoading = useSelector((state) => state.account.isLoading); const isLoadingEmail = useSelector((state) => state.account.isLoadingEmail); const messageEmail = useSelector((state) => state.account.message); + const isLoadingPassword = useSelector( + (state) => state.account.isLoadingPassword + ); const dispatch = useDispatch(); const navigate = useNavigate(); @@ -49,10 +52,6 @@ const Account = () => { } else { dispatch(getUserAccount(uuid)); } - - if (error !== null || successMsg !== null) { - dispatch(resetMessages()); - } }); const validateForm = () => { @@ -229,9 +228,8 @@ const Account = () => { {fromValidationErrors.password && (

{fromValidationErrors.password}

)} -

- {error ? error : messageEmail} -

+

{error}

+

{messageEmail}

@@ -239,7 +237,7 @@ const Account = () => { Close diff --git a/registry/src/store/actions/accountActions.js b/registry/src/store/actions/accountActions.js index 67b561b0..c961ae82 100644 --- a/registry/src/store/actions/accountActions.js +++ b/registry/src/store/actions/accountActions.js @@ -45,6 +45,7 @@ export const getUserAccount = (uuid) => async (dispatch) => { export const reset = (oldpassword, password, uuid) => async (dispatch) => { let formData = new FormData(); + dispatch({ type: RESET_PASSWORD }); formData.append("oldpassword", oldpassword); formData.append("password", password); formData.append("uuid", uuid); diff --git a/registry/src/store/reducers/accountReducer.js b/registry/src/store/reducers/accountReducer.js index 53e05cd4..4849d54d 100644 --- a/registry/src/store/reducers/accountReducer.js +++ b/registry/src/store/reducers/accountReducer.js @@ -17,6 +17,7 @@ const initialState = { dateJoined: "", isLoading: true, isLoadingEmail: false, + isLoadingPassword: false, message: null, resetPasswordSuccessMsg: null, }; @@ -34,6 +35,7 @@ const accountReducer = (state = initialState, action) => { return { ...state, resetPasswordSuccessMsg: action.payload, + isLoadingPassword: true, }; case CHANGE_EMAIL_SUCCESS: return { @@ -57,11 +59,13 @@ const accountReducer = (state = initialState, action) => { return { ...state, message: action.payload, + isLoadingPassword: false, }; case RESET_PASSWORD_ERROR: return { ...state, error: action.payload, + isLoadingPassword: false, }; case RESET_MESSAGES: return {