Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh the client bid list when a client bidding action is performed #723

Merged
merged 3 commits into from
Feb 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;)

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