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

new sort added #1368

Merged
merged 4 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ class PositionManagerDetails extends Component {

onSort = sort => {
this.setState({ ordering: sort }, () => {
this.props.getAllBids();
this.props.getBidsRanking(this.state.id);
const { id, ordering, filters } = this.state;
const query = {
...filters,
ordering,
};
this.props.getAllBids(id, query);
this.props.getBidsRanking(id);
});
}

Expand Down
1 change: 1 addition & 0 deletions src/Constants/Sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export const BUREAU_BIDDER_SORT = {
{ value: 'bidder_ted', text: 'TED' },
{ value: 'bidder_langauge', text: "Bidder's Langauge" },
{ value: 'bidder_name', text: "Bidder's Name" },
{ value: 'bidder_bid_submitted_date', text: 'Bid Submitted Date' },
// What order do we want these in?
Comment on lines +173 to 174

Choose a reason for hiding this comment

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

I think this order is good as is. Pretty similar to the other sorts ordering given the difference in options.

],
};
Expand Down
7 changes: 5 additions & 2 deletions src/actions/bureauPositionBids.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,15 @@ export function bureauBidsFetchData(id, query = {}) {
};
}

export function bureauBidsAllFetchData(id) {
export function bureauBidsAllFetchData(id, query) {
let url = `/fsbid/bureau/positions/${id}/bids/`;
const sort = query.ordering;
if (sort) { url += `?ordering=${sort}`; }
Comment on lines +108 to +109

Choose a reason for hiding this comment

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

I wouldn't do it this way. Use q to build the params, that way there is no concern of it needing to be ?ordering=${sort} vs &ordering=${sort}

return (dispatch) => {
dispatch(bureauPositionBidsAllIsLoading(true));
dispatch(bureauPositionBidsAllHasErrored(false));
api()
.get(`/fsbid/bureau/positions/${id}/bids/`)
.get(url)
.then(({ data }) => data || [])
.then((bids) => {
dispatch(bureauPositionBidsAllFetchDataSuccess(bids));
Expand Down
12 changes: 7 additions & 5 deletions src/actions/bureauPositionBids.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const { mockStore } = setupAsyncMocks();
describe('async actions', () => {
let mock;
let spy;

const query = {
ordering: 'bidder_name',
};
it('fetches bureauBidsFetchData', (done) => {
const store = mockStore({});

Expand Down Expand Up @@ -35,10 +37,10 @@ describe('async actions', () => {
const store = mockStore({});

({ mock, spy } = spyMockAdapter({
url: '/fsbid/bureau/positions/1/bids/', response: [200, []],
url: '/fsbid/bureau/positions/1/bids/?ordering=bidder_name', response: [200, []],
})); mock();

store.dispatch(actions.bureauBidsAllFetchData(1));
store.dispatch(actions.bureauBidsAllFetchData(1, query));

expectMockWasCalled({ spy, cb: done });
});
Expand All @@ -47,10 +49,10 @@ describe('async actions', () => {
const store = mockStore({});

({ mock, spy } = spyMockAdapter({
url: '/fsbid/bureau/positions/1/bids/', response: [404, null],
url: '/fsbid/bureau/positions/1/bids/?ordering=bidder_name', response: [404, null],
})); mock();

store.dispatch(actions.bureauBidsAllFetchData(1));
store.dispatch(actions.bureauBidsAllFetchData(1, query));

expectMockWasCalled({ spy, cb: done });
});
Expand Down