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

Fix bid tracker URL #863

Merged
merged 6 commits into from
Apr 29, 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
5 changes: 4 additions & 1 deletion src/Components/BidTracker/BidTrackerCard/BidTrackerCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class BidTrackerCard extends Component {
}
render() {
const { bid, acceptBid, condensedView, declineBid, priorityExists, submitBid, deleteBid,
registerHandshake, showBidCount, /* userProfile, */ useCDOView } = this.props;
registerHandshake, showBidCount, /* userProfile, */ useCDOView, userId } = this.props;
// determine whether we render an alert on top of the card
const showAlert = shouldShowAlert(bid, { condensedView });
// determine whether we should show the contacts section based on the status
Expand Down Expand Up @@ -68,6 +68,7 @@ class BidTrackerCard extends Component {
declineBid={declineBid}
submitBid={submitBid}
deleteBid={deleteBid}
userId={userId}
registerHandshake={registerHandshake}
/>
}
Expand Down Expand Up @@ -112,6 +113,7 @@ BidTrackerCard.propTypes = {
priorityExists: PropTypes.bool,
useCDOView: PropTypes.bool,
readOnly: PropTypes.bool,
userId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
};

BidTrackerCard.defaultProps = {
Expand All @@ -123,6 +125,7 @@ BidTrackerCard.defaultProps = {
priorityExists: false,
useCDOView: false,
readOnly: false,
userId: '',
};

BidTrackerCard.childContextTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ exports[`BidTrackerCardComponent matches snapshot 1`] = `
deleteBid={[Function]}
registerHandshake={[Function]}
submitBid={[Function]}
userId=""
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ exports[`BidTrackerCardContainerComponent matches snapshot when priorityExists i
showBidCount={true}
submitBid={[Function]}
useCDOView={false}
userId=""
userProfile={
Object {
"bid_statistics": Array [
Expand Down Expand Up @@ -261,6 +262,7 @@ exports[`BidTrackerCardContainerComponent matches snapshot when priorityExists i
showBidCount={false}
submitBid={[Function]}
useCDOView={false}
userId=""
userProfile={
Object {
"bid_statistics": Array [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import LinkButton from '../../../LinkButton';


const ClosedAlert = ({ title, date, id }, { condensedView }) => (
const ClosedAlert = ({ title, date, bidIdUrl }, { condensedView }) => (
<div className="bid-tracker-alert-container bid-tracker-alert-container--closed">
<div className="top-text">
Your bid on {title} is no longer applicable.
Expand All @@ -17,7 +17,7 @@ const ClosedAlert = ({ title, date, id }, { condensedView }) => (
{
condensedView &&
<div className="usa-grid-full">
<LinkButton toLink={`/profile/bidtracker/${id || ''}`} className="tm-button-transparent">
<LinkButton toLink={bidIdUrl} className="tm-button-transparent">
Go to Bid Tracker
</LinkButton>
</div>
Expand All @@ -28,12 +28,12 @@ const ClosedAlert = ({ title, date, id }, { condensedView }) => (
ClosedAlert.propTypes = {
title: PropTypes.string.isRequired,
date: PropTypes.string,
id: PropTypes.number,
bidIdUrl: PropTypes.string,
};

ClosedAlert.defaultProps = {
id: 0,
date: '',
bidIdUrl: '',
};

ClosedAlert.contextTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React from 'react';
import PropTypes from 'prop-types';
import LinkButton from '../../../LinkButton';

const DeclinedAlert = ({ bureau, id }, { condensedView }) => (
const DeclinedAlert = ({ bureau, bidIdUrl }, { condensedView }) => (
<div className="bid-tracker-alert-container bid-tracker-alert-container--declined">
<div className="top-text">
{bureau || 'The bureau'} has <strong>declined</strong> the bid
</div>
{
condensedView &&
<div className="usa-grid-full">
<LinkButton toLink={`/profile/bidtracker/${id || ''}`} className="tm-button-transparent">
<LinkButton toLink={bidIdUrl} className="tm-button-transparent">
Go to Bid Tracker
</LinkButton>
</div>
Expand All @@ -20,11 +20,11 @@ const DeclinedAlert = ({ bureau, id }, { condensedView }) => (

DeclinedAlert.propTypes = {
bureau: PropTypes.string.isRequired,
id: PropTypes.number,
bidIdUrl: PropTypes.string,
};

DeclinedAlert.defaultProps = {
id: 0,
bidIdUrl: '',
};

DeclinedAlert.contextTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import LinkButton from '../../../LinkButton';

const HandshakeDeclinedAlert = ({ userName, bureau, id }, { condensedView }) => (
const HandshakeDeclinedAlert = ({ userName, bureau, bidIdUrl }, { condensedView }) => (
<div
className="bid-tracker-alert-container bid-tracker-alert-container--handshake-declined"
>
Expand All @@ -17,7 +17,7 @@ const HandshakeDeclinedAlert = ({ userName, bureau, id }, { condensedView }) =>
{
condensedView &&
<div className="usa-grid-full">
<LinkButton toLink={`/profile/bidtracker/${id || ''}`} className="tm-button-transparent">
<LinkButton toLink={bidIdUrl} className="tm-button-transparent">
Go to Bid Tracker
</LinkButton>
</div>
Expand All @@ -28,11 +28,11 @@ const HandshakeDeclinedAlert = ({ userName, bureau, id }, { condensedView }) =>
HandshakeDeclinedAlert.propTypes = {
userName: PropTypes.string.isRequired,
bureau: PropTypes.string.isRequired,
id: PropTypes.number,
bidIdUrl: PropTypes.string,
};

HandshakeDeclinedAlert.defaultProps = {
id: 0,
bidIdUrl: '',
};

HandshakeDeclinedAlert.contextTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class HandshakeOfferedAlert extends Component {
};

render() {
const { userName, id } = this.props;
const { userName, bidIdUrl } = this.props;
const { condensedView } = this.context;
return (
<div className="bid-tracker-alert-container bid-tracker-alert-container--handshake-offered">
<div className="top-text">{`${userName}, you've been offered a handshake`}</div>
<div className="usa-grid-full">
{
condensedView ?
<LinkButton toLink={`/profile/bidtracker/${id}`} className="tm-button-transparent">
<LinkButton toLink={bidIdUrl} className="tm-button-transparent">
Go to Bid Tracker
</LinkButton>
:
Expand All @@ -46,6 +46,11 @@ HandshakeOfferedAlert.propTypes = {
userName: PropTypes.string.isRequired,
acceptBid: PropTypes.func.isRequired,
declineBid: PropTypes.func.isRequired,
bidIdUrl: PropTypes.string,
};

HandshakeOfferedAlert.defaultProps = {
bidIdUrl: '',
};

HandshakeOfferedAlert.contextTypes = {
Expand Down
35 changes: 24 additions & 11 deletions src/Components/BidTracker/OverlayAlert/OverlayAlert.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import React from 'react';
import PropTypes from 'prop-types';
import { BID_OBJECT } from '../../../Constants/PropTypes';
import { BID_OBJECT } from 'Constants/PropTypes';
import { APPROVED_PROP, CLOSED_PROP, HAND_SHAKE_OFFERED_PROP, DRAFT_PROP,
HAND_SHAKE_DECLINED_PROP, IN_PANEL_PROP, DECLINED_PROP, PANEL_RESCHEDULED_PROP, HAND_SHAKE_NEEDS_REGISTER_PROP } from '../../../Constants/BidData';
HAND_SHAKE_DECLINED_PROP, IN_PANEL_PROP, DECLINED_PROP, PANEL_RESCHEDULED_PROP,
HAND_SHAKE_NEEDS_REGISTER_PROP } from 'Constants/BidData';
import ApprovedAlert from './ApprovedAlert';
import HandshakeOfferedAlert from './HandshakeOfferedAlert';
import InPanelAlert from './InPanelAlert';
import HandshakeDeclinedAlert from './HandshakeDeclinedAlert';
import DeclinedAlert from './DeclinedAlert';
import ClosedAlert from './ClosedAlert';
import PanelRescheduledAlert from './PanelRescheduledAlert';
import DraftAlert from './DraftAlert';
import HandshakeRegisterAlert from './HandshakeRegisterAlert';
import DraftAlert from './DraftAlert';
import { getBidIdUrl } from './helpers';

// Alert rendering based on status is handled here.
// eslint-disable-next-line complexity
const OverlayAlert = (
{ bid, acceptBid, declineBid, submitBid, registerHandshake },
{ condensedView }) => {
const OverlayAlert = ({ bid, acceptBid, declineBid, submitBid, userId, registerHandshake },
{ condensedView, readOnly }) => {
const CLASS_PENDING = 'bid-tracker-overlay-alert--pending';
const CLASS_SUCCESS = 'bid-tracker-overlay-alert--success';
const CLASS_CLOSED = 'bid-tracker-overlay-alert--closed';
Expand All @@ -27,6 +28,8 @@ const OverlayAlert = (
const { position } = bid;
const BID_TITLE = `${position.title}${position.position_number ? ` (${position.position_number})` : ''}`;

const bidIdUrl = getBidIdUrl(bid.id, readOnly, userId);

let overlayClass = '';
let overlayContent = '';

Expand All @@ -50,7 +53,6 @@ const OverlayAlert = (
overlayClass = CLASS_REGISTER;
overlayContent = (
<HandshakeRegisterAlert
id={bid.id}
registerHandshake={registerHandshake}
bid={bid}
/>);
Expand All @@ -66,6 +68,7 @@ const OverlayAlert = (
userName={bid.user}
acceptBid={acceptBid}
declineBid={declineBid}
bidIdUrl={bidIdUrl}
/>
);
break;
Expand All @@ -78,17 +81,22 @@ const OverlayAlert = (
<HandshakeDeclinedAlert
userName={bid.user}
bureau={position.bureau}
id={bid.id}
bidIdUrl={bidIdUrl}
/>
);
break;
case DECLINED_PROP:
overlayClass = CLASS_CLOSED;
overlayContent = <DeclinedAlert bureau={position.bureau} id={bid.id} />;
overlayContent = <DeclinedAlert bureau={position.bureau} id={bid.id} bidIdUrl={bidIdUrl} />;

Choose a reason for hiding this comment

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

Same as other comment: id

Copy link
Author

Choose a reason for hiding this comment

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

Good catch, removed. Re-running tests now

break;
case CLOSED_PROP:
overlayClass = CLASS_CLOSED;
overlayContent = <ClosedAlert title={BID_TITLE} date={bid.closed_date} id={bid.id} />;
overlayContent =
(<ClosedAlert
title={BID_TITLE}
date={bid.closed_date}
bidIdUrl={bidIdUrl}
/>);
break;
case PANEL_RESCHEDULED_PROP:
overlayClass = CLASS_PENDING;
Expand All @@ -98,7 +106,6 @@ const OverlayAlert = (
overlayClass = CLASS_DRAFT;
overlayContent = (
<DraftAlert
id={bid.id}
bid={bid}
submitBid={submitBid}
/>);
Expand All @@ -122,11 +129,17 @@ OverlayAlert.propTypes = {
acceptBid: PropTypes.func.isRequired,
declineBid: PropTypes.func.isRequired,
submitBid: PropTypes.func.isRequired,
userId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
registerHandshake: PropTypes.func.isRequired,
};

OverlayAlert.defaultProps = {
userId: '',
};

OverlayAlert.contextTypes = {
condensedView: PropTypes.bool,
readOnly: PropTypes.bool,
};

export default OverlayAlert;
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ exports[`OverlayAlertComponent matches snapshot when type is "closed" 1`] = `
className="bid-tracker-overlay-alert-content"
>
<ClosedAlert
bidIdUrl="/profile/bidtracker/3"
date="2017-12-20"
id={3}
title="POLITICAL/ECONOMIC OFFICER (10035561)"
/>
</div>
Expand All @@ -47,6 +47,7 @@ exports[`OverlayAlertComponent matches snapshot when type is "declined" 1`] = `
className="bid-tracker-overlay-alert-content"
>
<DeclinedAlert
bidIdUrl="/profile/bidtracker/3"
bureau="(AF) BUREAU OF AFRICAN AFFAIRS"
id={3}
/>
Expand Down Expand Up @@ -117,7 +118,6 @@ exports[`OverlayAlertComponent matches snapshot when type is "draft" 1`] = `
"user": "rehmant",
}
}
id={3}
submitBid={[Function]}
/>
</div>
Expand Down Expand Up @@ -150,8 +150,8 @@ exports[`OverlayAlertComponent matches snapshot when type is "handshake_declined
className="bid-tracker-overlay-alert-content"
>
<HandshakeDeclinedAlert
bidIdUrl="/profile/bidtracker/3"
bureau="(AF) BUREAU OF AFRICAN AFFAIRS"
id={3}
userName="rehmant"
/>
</div>
Expand Down Expand Up @@ -221,7 +221,6 @@ exports[`OverlayAlertComponent matches snapshot when type is "handshake_needs_re
"user": "rehmant",
}
}
id={3}
registerHandshake={[Function]}
/>
</div>
Expand All @@ -241,6 +240,7 @@ exports[`OverlayAlertComponent matches snapshot when type is "handshake_offered"
>
<HandshakeOfferedAlert
acceptBid={[Function]}
bidIdUrl="/profile/bidtracker/3"
declineBid={[Function]}
id={3}
userName="rehmant"
Expand Down
12 changes: 12 additions & 0 deletions src/Components/BidTracker/OverlayAlert/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const getBidIdUrl = (id = '', isPublic = false, userId = '') => {
let url = '/profile/bidtracker';
if (isPublic && userId) {
url = `${url}/public/${userId}`;
}
if (id) {
url = `${url}/${id}`;
}
return url;
};

export default getBidIdUrl;
1 change: 1 addition & 0 deletions src/Components/ProfileDashboard/BidList/BidList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const BidList = ({ bids, submitBidPosition, deleteBid, registerHandshake, isLoad
deleteBid={deleteBid}
priorityExists={doesPriorityExist}
readOnly={isPublic}
userId={userId}
/>
));
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ exports[`BidListComponent matches snapshot 1`] = `
showBidCount={true}
submitBid={[Function]}
useCDOView={false}
userId=""
/>
<BidTrackerCard
acceptBid={[Function]}
Expand Down Expand Up @@ -163,6 +164,7 @@ exports[`BidListComponent matches snapshot 1`] = `
showBidCount={true}
submitBid={[Function]}
useCDOView={false}
userId=""
/>
<BidTrackerCard
acceptBid={[Function]}
Expand Down Expand Up @@ -230,6 +232,7 @@ exports[`BidListComponent matches snapshot 1`] = `
showBidCount={true}
submitBid={[Function]}
useCDOView={false}
userId=""
/>
</div>
<div
Expand Down
Loading