Skip to content

Commit

Permalink
Merge pull request #2866 from OneCommunityGlobal/ashish_fix_rehireabl…
Browse files Browse the repository at this point in the history
…e_status

Ashish_Fix_Rehireable_Status
  • Loading branch information
one-community authored Dec 14, 2024
2 parents 78df663 + 298698e commit 00e31e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/actions/userManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ export const updateUserStatus = (user, status, reactivationDate) => {
* @param{boolean} isRehireable - the new rehireable status
*/
export const updateRehireableStatus = (user, isRehireable) => {
const userProfile = { ...user };
userProfile.isRehireable = isRehireable
const requestData = { isRehireable };

const updateProfilePromise = axios.patch(ENDPOINTS.UPDATE_REHIREABLE_STATUS(user._id), requestData)
return async dispatch => {
updateProfilePromise.then(res => {
const userProfile = { ...user, isRehireable };
const requestData = { isRehireable };
try {
await axios.patch(ENDPOINTS.UPDATE_REHIREABLE_STATUS(user._id), requestData);
dispatch(userProfileUpdateAction(userProfile));
});
} catch (err) {
throw err;
}
};
};

Expand Down
14 changes: 9 additions & 5 deletions src/components/UserProfile/UserProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -666,16 +666,20 @@ function UserProfile(props) {
setShowConfirmDialog(true);
};

const handleConfirmChange = () => {
const handleConfirmChange = async () => {
setShowConfirmDialog(false);
const updatedUserProfile = {
...userProfile,
isRehireable: pendingRehireableStatus,
};
updateRehireableStatus(updatedUserProfile, pendingRehireableStatus);
setIsRehireable(pendingRehireableStatus);
setUserProfile(updatedUserProfile);
setOriginalUserProfile(updatedUserProfile);
try{
await dispatch(updateRehireableStatus(updatedUserProfile, pendingRehireableStatus));
setIsRehireable(pendingRehireableStatus);
setUserProfile(updatedUserProfile);
setOriginalUserProfile(updatedUserProfile);
}catch(error){
toast.error('Unable change rehireable status');
}
};

const handleCancelChange = () => {
Expand Down

0 comments on commit 00e31e8

Please sign in to comment.