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

MAIN- B-19713-UI-Address-PPM-Shipment-Card #13002

Merged
merged 5 commits into from
Jun 12, 2024
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
32 changes: 24 additions & 8 deletions src/components/PPMSummaryList/PPMSummaryList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,23 @@ import styles from './PPMSummaryList.module.scss';
import SectionWrapper from 'components/Customer/SectionWrapper';
import { ppmShipmentStatuses } from 'constants/shipments';
import { ShipmentShape } from 'types/shipment';
import { formatCustomerDate } from 'utils/formatters';
import { formatCustomerDate, formatAddressShort } from 'utils/formatters';
import AsyncPacketDownloadLink from 'shared/AsyncPacketDownloadLink/AsyncPacketDownloadLink';
import { downloadPPMPaymentPacket } from 'services/internalApi';

const toFromAddressDisplay = (pickupAddress, destinationAddress) => {
return (
<div className={styles.addressDisplay}>
<p>
<span className={styles.bold}>From: </span>
{formatAddressShort(pickupAddress)}
<span className={styles.bold}> To: </span>
{formatAddressShort(destinationAddress)}
</p>
</div>
);
};

const submittedContent = (
<>
<p>After a counselor approves your PPM, you will be able to:</p>
Expand All @@ -21,9 +34,10 @@ const submittedContent = (
</>
);

const approvedContent = (approvedAt) => {
const approvedContent = (approvedAt, pickupAddress, destinationAddress) => {
return (
<>
{toFromAddressDisplay(pickupAddress, destinationAddress)}
<div className={styles.dateSummary}>
<p>{`PPM approved: ${formatCustomerDate(approvedAt)}.`}</p>
</div>
Expand All @@ -37,9 +51,10 @@ const approvedContent = (approvedAt) => {
);
};

const paymentSubmitted = (approvedAt, submittedAt) => {
const paymentSubmitted = (approvedAt, submittedAt, pickupAddress, destinationAddress) => {
return (
<>
{toFromAddressDisplay(pickupAddress, destinationAddress)}
<div className={styles.dateSummary}>
<p>{`PPM approved: ${formatCustomerDate(approvedAt)}`}</p>
<p>{`PPM documentation submitted: ${formatCustomerDate(submittedAt)}`}</p>
Expand All @@ -54,9 +69,10 @@ const paymentSubmitted = (approvedAt, submittedAt) => {
);
};

const paymentReviewed = (approvedAt, submittedAt, reviewedAt) => {
const paymentReviewed = (approvedAt, submittedAt, reviewedAt, pickupAddress, destinationAddress) => {
return (
<>
{toFromAddressDisplay(pickupAddress, destinationAddress)}
<div className={styles.dateSummary}>
<p>{`PPM approved: ${formatCustomerDate(approvedAt)}`}</p>
<p>{`PPM documentation submitted: ${formatCustomerDate(submittedAt)}`}</p>
Expand All @@ -74,7 +90,7 @@ const paymentReviewed = (approvedAt, submittedAt, reviewedAt) => {

const PPMSummaryStatus = (shipment, orderLabel, onButtonClick, onDownloadError) => {
const {
ppmShipment: { status, approvedAt, submittedAt, reviewedAt },
ppmShipment: { status, approvedAt, submittedAt, reviewedAt, pickupAddress, destinationAddress },
} = shipment;

let actionButton;
Expand All @@ -87,11 +103,11 @@ const PPMSummaryStatus = (shipment, orderLabel, onButtonClick, onDownloadError)
break;
case ppmShipmentStatuses.WAITING_ON_CUSTOMER:
actionButton = <Button onClick={onButtonClick}>Upload PPM Documents</Button>;
content = approvedContent(approvedAt);
content = approvedContent(approvedAt, pickupAddress, destinationAddress);
break;
case ppmShipmentStatuses.NEEDS_CLOSEOUT:
actionButton = <Button disabled>Download Payment Packet</Button>;
content = paymentSubmitted(approvedAt, submittedAt);
content = paymentSubmitted(approvedAt, submittedAt, pickupAddress, destinationAddress);
break;
case ppmShipmentStatuses.CLOSEOUT_COMPLETE:
actionButton = (
Expand All @@ -104,7 +120,7 @@ const PPMSummaryStatus = (shipment, orderLabel, onButtonClick, onDownloadError)
/>
);

content = paymentReviewed(approvedAt, submittedAt, reviewedAt);
content = paymentReviewed(approvedAt, submittedAt, reviewedAt, pickupAddress, destinationAddress);
break;
default:
}
Expand Down
9 changes: 9 additions & 0 deletions src/components/PPMSummaryList/PPMSummaryList.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
@include u-margin-bottom(2);
}

.addressDisplay {
@include u-margin-top(2);
@include u-margin-bottom(2);
}

.bold {
font-weight: bold;
}

&:last-of-type {
@include u-margin-bottom(0);
}
Expand Down
96 changes: 96 additions & 0 deletions src/components/PPMSummaryList/PPMSummaryList.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ Submitted.args = {
status: ppmShipmentStatuses.SUBMITTED,
hasRequestedAdvance: true,
advanceAmountRequested: 10000,
pickupAddress: {
streetAddress1: '1 Test Street',
streetAddress2: '2 Test Street',
streetAddress3: '3 Test Street',
city: 'Pickup Test City',
state: 'NY',
postalCode: '10001',
},
destinationAddress: {
streetAddress1: '1 Test Street',
streetAddress2: '2 Test Street',
streetAddress3: '3 Test Street',
city: 'Destination Test City',
state: 'NY',
postalCode: '11111',
},
},
},
],
Expand All @@ -42,6 +58,22 @@ Approved.args = {
approvedAt: '2022-04-15T15:38:07.103Z',
hasRequestedAdvance: true,
advanceAmountRequested: 10000,
pickupAddress: {
streetAddress1: '1 Test Street',
streetAddress2: '2 Test Street',
streetAddress3: '3 Test Street',
city: 'Pickup Test City',
state: 'NY',
postalCode: '10001',
},
destinationAddress: {
streetAddress1: '1 Test Street',
streetAddress2: '2 Test Street',
streetAddress3: '3 Test Street',
city: 'Destination Test City',
state: 'NY',
postalCode: '11111',
},
},
},
],
Expand All @@ -59,6 +91,22 @@ ApprovedMultiple.args = {
approvedAt: '2022-04-15T15:38:07.103Z',
hasRequestedAdvance: true,
advanceAmountRequested: 10000,
pickupAddress: {
streetAddress1: '1 Test Street',
streetAddress2: '2 Test Street',
streetAddress3: '3 Test Street',
city: 'Pickup Test City',
state: 'NY',
postalCode: '10001',
},
destinationAddress: {
streetAddress1: '1 Test Street',
streetAddress2: '2 Test Street',
streetAddress3: '3 Test Street',
city: 'Destination Test City',
state: 'NY',
postalCode: '11111',
},
},
},
{
Expand All @@ -70,6 +118,22 @@ ApprovedMultiple.args = {
approvedAt: '2022-04-20T15:38:07.103Z',
hasRequestedAdvance: true,
advanceAmountRequested: 10000,
pickupAddress: {
streetAddress1: '1 Test Street',
streetAddress2: '2 Test Street',
streetAddress3: '3 Test Street',
city: 'Pickup Test City',
state: 'NY',
postalCode: '10001',
},
destinationAddress: {
streetAddress1: '1 Test Street',
streetAddress2: '2 Test Street',
streetAddress3: '3 Test Street',
city: 'Destination Test City',
state: 'NY',
postalCode: '11111',
},
},
},
],
Expand All @@ -88,6 +152,22 @@ PaymentSubmitted.args = {
submittedAt: '2022-04-19T15:38:07.103Z',
hasRequestedAdvance: true,
advanceAmountRequested: 10000,
pickupAddress: {
streetAddress1: '1 Test Street',
streetAddress2: '2 Test Street',
streetAddress3: '3 Test Street',
city: 'Pickup Test City',
state: 'NY',
postalCode: '10001',
},
destinationAddress: {
streetAddress1: '1 Test Street',
streetAddress2: '2 Test Street',
streetAddress3: '3 Test Street',
city: 'Destination Test City',
state: 'NY',
postalCode: '11111',
},
},
},
],
Expand All @@ -107,6 +187,22 @@ PaymentReviewed.args = {
reviewedAt: '2022-04-23T15:38:07.103Z',
hasRequestedAdvance: true,
advanceAmountRequested: 10000,
pickupAddress: {
streetAddress1: '1 Test Street',
streetAddress2: '2 Test Street',
streetAddress3: '3 Test Street',
city: 'Pickup Test City',
state: 'NY',
postalCode: '10001',
},
destinationAddress: {
streetAddress1: '1 Test Street',
streetAddress2: '2 Test Street',
streetAddress3: '3 Test Street',
city: 'Destination Test City',
state: 'NY',
postalCode: '11111',
},
},
},
],
Expand Down
Loading
Loading