Skip to content

Commit

Permalink
Merge pull request #723 from MetaPhase-Consulting/fix/refresh-client-…
Browse files Browse the repository at this point in the history
…bidlist

Refresh the client bid list when a client bidding action is performed
  • Loading branch information
mjoyce91 committed Feb 24, 2020
2 parents b185789 + c83b3a7 commit 3b125c9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/actions/userProfilePublic.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from 'axios';
import { get } from 'lodash';
import { get, isArray } from 'lodash';
import { clientBidListFetchDataSuccess } from './bidList';
import api from '../api';

export function userProfilePublicHasErrored(bool) {
Expand Down Expand Up @@ -31,7 +32,7 @@ export function unsetUserProfilePublic() {

// include an optional bypass for when we want to silently update the profile
export function userProfilePublicFetchData(id, bypass) {
return (dispatch) => {
return (dispatch, getState) => {
if (!bypass) {
dispatch(userProfilePublicIsLoading(true));
dispatch(userProfilePublicHasErrored(false));
Expand Down Expand Up @@ -73,6 +74,15 @@ export function userProfilePublicFetchData(id, bypass) {
dispatch(userProfilePublicFetchDataSuccess(newProfileObject));
dispatch(userProfilePublicIsLoading(false));
dispatch(userProfilePublicHasErrored(false));

// Set this user's bid list to the clientView's bid list, if they are the same user.
const clientView = get(getState(), 'clientView');
const selectedEmpId = get(clientView, 'client.employee_id');
const empId = get(newProfileObject, 'employee_id');
if (empId && selectedEmpId &&
empId === selectedEmpId && isArray(newProfileObject.bidList)) {
dispatch(clientBidListFetchDataSuccess({ results: newProfileObject.bidList }));
}
}
}))
.catch(() => {
Expand Down

0 comments on commit 3b125c9

Please sign in to comment.