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

Add export bid list button to personal bid tracker #837

Merged
merged 1 commit into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
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
26 changes: 25 additions & 1 deletion src/Components/BidTracker/BidTracker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { get, find, orderBy, reverse } from 'lodash';
import Alert from 'Components/Alert';
import ExportButton from 'Components/ExportButton';
import SearchAsClientButton from 'Components/BidderPortfolio/SearchAsClientButton/SearchAsClientButton';
import SelectForm from 'Components/SelectForm';
import { BID_STATUS_ORDER } from 'Constants/BidStatuses';
import { downloadBidlistData } from 'actions/bidList';
import { BID_LIST, NOTIFICATION_LIST, USER_PROFILE } from '../../Constants/PropTypes';
import BidTrackerCardList from './BidTrackerCardList';
import ProfileSectionTitle from '../ProfileSectionTitle';
Expand All @@ -30,13 +32,18 @@ class BidTracker extends Component {
super(props);
this.state = {
sortValue: find(SORT_OPTIONS, f => f.defaultSort).value,
exportIsLoading: false,
};
}

onSelectOption = e => {
this.setState({ sortValue: get(e, 'target.value') });
};

setIsLoading = exportIsLoading => {
this.setState({ exportIsLoading });
};

getSortedBids() {
const { sortValue } = this.state;
const results = get(this.props, 'bidList.results', []);
Expand All @@ -58,8 +65,19 @@ class BidTracker extends Component {
return results$;
}

exportBidlistData = () => {
this.setIsLoading(true);
downloadBidlistData()
.then(() => {
this.setIsLoading(false);
})
.catch(() => {
this.setIsLoading(false);
});
}

render() {
const { sortValue } = this.state;
const { exportIsLoading, sortValue } = this.state;
const { bidList, bidListIsLoading, acceptBid, declineBid, submitBid, deleteBid,
notifications, notificationsIsLoading, markBidTrackerNotification, userProfile,
userProfileIsLoading, isPublic, useCDOView } = this.props;
Expand Down Expand Up @@ -113,6 +131,12 @@ class BidTracker extends Component {
onSelectOption={this.onSelectOption}
/>
</div>
{
!isPublic &&
<div className="export-button-container">
<ExportButton onClick={this.exportBidlistData} isLoading={exportIsLoading} />
</div>
}
</div>
<div className="bid-tracker-content-container">
{
Expand Down
22 changes: 22 additions & 0 deletions src/Components/BidTracker/__snapshots__/BidTracker.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ exports[`BidTrackerComponent matches snapshot 1`] = `
transformValue={[Function]}
/>
</div>
<div
className="export-button-container"
>
<ExportButton
className=""
isLoading={false}
onClick={[Function]}
primaryClass="usa-button-secondary"
text="Export"
/>
</div>
</div>
<div
className="bid-tracker-content-container"
Expand Down Expand Up @@ -483,6 +494,17 @@ exports[`BidTrackerComponent matches snapshot when bidListIsLoading is true 1`]
transformValue={[Function]}
/>
</div>
<div
className="export-button-container"
>
<ExportButton
className=""
isLoading={false}
onClick={[Function]}
primaryClass="usa-button-secondary"
text="Export"
/>
</div>
</div>
<div
className="bid-tracker-content-container"
Expand Down
14 changes: 14 additions & 0 deletions src/actions/bidList.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import { batch } from 'react-redux';
import axios from 'axios';
import { get } from 'lodash';
import { downloadFromResponse } from 'utilities';
import api from '../api';
import { toastSuccess, toastError } from './toast';
import { userProfilePublicFetchData } from './userProfilePublic';
import * as SystemMessages from '../Constants/SystemMessages';

export function downloadBidlistData() {
return api().get('/fsbid/bidlist/export/', {
responseType: 'stream',
})
.then((response) => {
downloadFromResponse(response, 'TalentMap_BidList_export');
})
.catch(() => {
// eslint-disable-next-line global-require
require('../store').store.dispatch(toastError('Export unsuccessful. Please try again.', 'Error exporting'));

Choose a reason for hiding this comment

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

🍞

});
}

export function bidListHasErrored(bool) {
return {
type: 'BID_LIST_HAS_ERRORED',
Expand Down
8 changes: 8 additions & 0 deletions src/sass/_bidTracker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ $draft-icon-offset: 120px;
position: relative;

.searches-top-section {
display: flex;
justify-content: flex-end;
margin-bottom: 1.2em;
}

.export-button-container {
button {
margin-top: 0;

Choose a reason for hiding this comment

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

📃

}
}

.results-dropdown-sort {
float: right;

Choose a reason for hiding this comment

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

👻

}
Expand Down