From 257f72b2c3118f8f8b0d27e65861df569d53554b Mon Sep 17 00:00:00 2001 From: AaronW Date: Tue, 6 Feb 2024 21:33:48 +0000 Subject: [PATCH] -Implemented logic for the PPM-only adjustments detailed in the AC of this Agility ticket --- .../ImportantShipmentDates.jsx | 43 ++++++-- .../ImportantShipmentDates.test.jsx | 100 +++++++++++++++++- .../ShipmentDetails/ShipmentDetailsMain.jsx | 56 +++++++--- 3 files changed, 172 insertions(+), 27 deletions(-) diff --git a/src/components/Office/ImportantShipmentDates/ImportantShipmentDates.jsx b/src/components/Office/ImportantShipmentDates/ImportantShipmentDates.jsx index f27211335f9..f252763b7bc 100644 --- a/src/components/Office/ImportantShipmentDates/ImportantShipmentDates.jsx +++ b/src/components/Office/ImportantShipmentDates/ImportantShipmentDates.jsx @@ -9,26 +9,43 @@ import DataTableWrapper from 'components/DataTableWrapper/index'; const ImportantShipmentDates = ({ requestedPickupDate, + plannedMoveDate, scheduledPickupDate, - requiredDeliveryDate, + actualMoveDate, actualPickupDate, + requiredDeliveryDate, requestedDeliveryDate, scheduledDeliveryDate, actualDeliveryDate, + isPPM, }) => { + const headerPlannedMoveDate = isPPM ? 'Planned Move Date' : 'Requested pick up date'; + const headerActualMoveDate = isPPM ? 'Actual Move Date' : 'Scheduled pick up date'; + const headerActualPickupDate = isPPM ? '' : 'Actual pick up date'; + const emDash = '\u2014'; return (
- - - + {!isPPM && } + {!isPPM && ( + + )} + {isPPM && ( + + )} + {!isPPM && ( + + )}
); @@ -39,19 +56,25 @@ ImportantShipmentDates.defaultProps = { scheduledPickupDate: '', requiredDeliveryDate: '', actualPickupDate: '', + plannedMoveDate: '', + actualMoveDate: '', requestedDeliveryDate: '', scheduledDeliveryDate: '', actualDeliveryDate: '', + isPPM: false, }; ImportantShipmentDates.propTypes = { requestedPickupDate: PropTypes.string, scheduledPickupDate: PropTypes.string, + plannedMoveDate: PropTypes.string, + actualMoveDate: PropTypes.string, requiredDeliveryDate: PropTypes.string, actualPickupDate: PropTypes.string, requestedDeliveryDate: PropTypes.string, scheduledDeliveryDate: PropTypes.string, actualDeliveryDate: PropTypes.string, + isPPM: PropTypes.bool, }; export default ImportantShipmentDates; diff --git a/src/components/Office/ImportantShipmentDates/ImportantShipmentDates.test.jsx b/src/components/Office/ImportantShipmentDates/ImportantShipmentDates.test.jsx index ad9df37c3bc..1c31a8922e9 100644 --- a/src/components/Office/ImportantShipmentDates/ImportantShipmentDates.test.jsx +++ b/src/components/Office/ImportantShipmentDates/ImportantShipmentDates.test.jsx @@ -4,24 +4,29 @@ import { mount } from 'enzyme'; import ImportantShipmentDates from './ImportantShipmentDates'; describe('ImportantShipmentDates', () => { + const requiredDeliveryDate = 'Wednesday, 25 Mar 2020'; const requestedPickupDate = 'Thursday, 26 Mar 2020'; const scheduledPickupDate = 'Friday, 27 Mar 2020'; - const actualPickupDate = 'Saturday, 28 Mar 2020'; - const requiredDeliveryDate = 'Monday, 30 Mar 2020'; - const requestedDeliveryDate = 'Sunday, 29 Mar 2020'; + const plannedMoveDate = 'Saturday, 28 Mar 2020'; + const actualMoveDate = 'Sunday, 29 Mar 2020'; + const requestedDeliveryDate = 'Monday, 30 Mar 2020'; const scheduledDeliveryDate = 'Tuesday, 1 Apr 2020'; const actualDeliveryDate = 'Wednesday, 2 Apr 2020'; + const actualPickupDate = 'Thursday, 3 Apr 2020'; it('should render the shipment dates we pass in', () => { const wrapper = mount( , ); expect(wrapper.find('td').at(0).text()).toEqual(requiredDeliveryDate); @@ -42,6 +47,91 @@ describe('ImportantShipmentDates', () => { expect(wrapper.find('td').at(3).text()).toEqual(emDash); expect(wrapper.find('td').at(4).text()).toEqual(emDash); expect(wrapper.find('td').at(5).text()).toEqual(emDash); - expect(wrapper.find('td').at(6).text()).toEqual(emDash); + }); + + it('should show relevant PPM fields when it is a PPM', () => { + const wrapper = mount( + , + ); + expect(wrapper.find('td').at(0).text()).toEqual(plannedMoveDate); + expect(wrapper.find('td').at(1).text()).toEqual(actualMoveDate); + }); + + it('should not show irrelevant fields when it is a PPM', () => { + const wrapper = mount( + , + ); + expect(wrapper.find('td').at(0).text()).not.toEqual(requestedPickupDate); + expect(wrapper.find('td').at(1).text()).not.toEqual(requestedPickupDate); + expect(wrapper.find('td').at(0).text()).not.toEqual(scheduledPickupDate); + expect(wrapper.find('td').at(1).text()).not.toEqual(scheduledPickupDate); + expect(wrapper.find('td').at(0).text()).not.toEqual(requestedDeliveryDate); + expect(wrapper.find('td').at(1).text()).not.toEqual(requestedDeliveryDate); + expect(wrapper.find('td').at(0).text()).not.toEqual(scheduledDeliveryDate); + expect(wrapper.find('td').at(1).text()).not.toEqual(scheduledDeliveryDate); + expect(wrapper.find('td').at(0).text()).not.toEqual(actualDeliveryDate); + expect(wrapper.find('td').at(1).text()).not.toEqual(actualDeliveryDate); + }); + + it('should show relevant fields when it is a PPM', () => { + const wrapper = mount( + , + ); + expect(wrapper.find('td').at(0).text()).toEqual(plannedMoveDate); + expect(wrapper.find('td').at(1).text()).toEqual(actualMoveDate); + }); + + it('should not show irrelevant fields when it is a PPM', () => { + const wrapper = mount( + , + ); + expect(wrapper.find('td').at(0).text()).not.toEqual(requestedPickupDate); + expect(wrapper.find('td').at(1).text()).not.toEqual(requestedPickupDate); + expect(wrapper.find('td').at(0).text()).not.toEqual(scheduledPickupDate); + expect(wrapper.find('td').at(1).text()).not.toEqual(scheduledPickupDate); + expect(wrapper.find('td').at(0).text()).not.toEqual(requestedDeliveryDate); + expect(wrapper.find('td').at(1).text()).not.toEqual(requestedDeliveryDate); + expect(wrapper.find('td').at(0).text()).not.toEqual(scheduledDeliveryDate); + expect(wrapper.find('td').at(1).text()).not.toEqual(scheduledDeliveryDate); + expect(wrapper.find('td').at(0).text()).not.toEqual(actualDeliveryDate); + expect(wrapper.find('td').at(1).text()).not.toEqual(actualDeliveryDate); }); }); diff --git a/src/components/Office/ShipmentDetails/ShipmentDetailsMain.jsx b/src/components/Office/ShipmentDetails/ShipmentDetailsMain.jsx index e45f01a24c4..d02f6377fe4 100644 --- a/src/components/Office/ShipmentDetails/ShipmentDetailsMain.jsx +++ b/src/components/Office/ShipmentDetails/ShipmentDetailsMain.jsx @@ -125,27 +125,53 @@ const ShipmentDetailsMain = ({ let displayedPickupAddress; let displayedDeliveryAddress; + let weightResult; + let pickupRequestedDate; + let pickupScheduledDate; + let pickupActualDate; + let plannedMoveDate; let actualMoveDate; switch (shipmentType) { case SHIPMENT_OPTIONS.HHG: + pickupRequestedDate = requestedPickupDate; + pickupScheduledDate = scheduledPickupDate; + pickupActualDate = actualPickupDate; + weightResult = primeEstimatedWeight; displayedPickupAddress = pickupAddress; displayedDeliveryAddress = destinationAddress || destinationDutyLocationAddress; break; case SHIPMENT_OPTIONS.NTS: + pickupRequestedDate = requestedPickupDate; + pickupScheduledDate = scheduledPickupDate; + pickupActualDate = actualPickupDate; + weightResult = primeEstimatedWeight; displayedPickupAddress = pickupAddress; displayedDeliveryAddress = storageFacility ? storageFacility.address : null; break; case SHIPMENT_OPTIONS.NTSR: + pickupRequestedDate = requestedPickupDate; + pickupScheduledDate = scheduledPickupDate; + pickupActualDate = actualPickupDate; + weightResult = primeEstimatedWeight; displayedPickupAddress = storageFacility ? storageFacility.address : null; displayedDeliveryAddress = destinationAddress; break; case SHIPMENT_OPTIONS.PPM: + plannedMoveDate = ppmShipment.expectedDepartureDate; actualMoveDate = ppmShipment.actualMoveDate; + weightResult = ppmShipment.estimatedWeight; + displayedPickupAddress = pickupAddress; + displayedDeliveryAddress = destinationAddress || destinationDutyLocationAddress; break; default: + pickupRequestedDate = requestedPickupDate; + pickupScheduledDate = scheduledPickupDate; + pickupActualDate = actualPickupDate; + weightResult = primeEstimatedWeight; displayedPickupAddress = pickupAddress; displayedDeliveryAddress = destinationAddress || destinationDutyLocationAddress; + break; } return ( @@ -189,19 +215,25 @@ const ShipmentDetailsMain = ({ )} {shipmentType === SHIPMENT_OPTIONS.PPM && ( + )} + {shipmentType !== SHIPMENT_OPTIONS.PPM && ( + )} -