From 57e740f2940912bdce399b877bc49da8bb0a1827 Mon Sep 17 00:00:00 2001 From: Alex Lusk Date: Fri, 8 Nov 2024 00:35:52 +0000 Subject: [PATCH 01/38] Add zip city lookup to origin SIT Service Item Form --- .../OriginSITServiceItemForm.jsx | 76 ++++++++++++++----- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/src/components/PrimeUI/CreateShipmentServiceItemForm/OriginSITServiceItemForm.jsx b/src/components/PrimeUI/CreateShipmentServiceItemForm/OriginSITServiceItemForm.jsx index 5135f3da031..c1dfb8c7012 100644 --- a/src/components/PrimeUI/CreateShipmentServiceItemForm/OriginSITServiceItemForm.jsx +++ b/src/components/PrimeUI/CreateShipmentServiceItemForm/OriginSITServiceItemForm.jsx @@ -2,6 +2,7 @@ import * as Yup from 'yup'; import { Formik } from 'formik'; import { Button } from '@trussworks/react-uswds'; import React from 'react'; +import { useNavigate, useParams, generatePath } from 'react-router-dom'; import PropTypes from 'prop-types'; import { requiredAddressSchema, ZIP_CODE_REGEX } from 'utils/validation'; @@ -13,6 +14,7 @@ import MaskedTextField from 'components/form/fields/MaskedTextField/MaskedTextFi import { DatePickerInput } from 'components/form/fields'; import { AddressFields } from 'components/form/AddressFields/AddressFields'; import { ShipmentShape } from 'types/shipment'; +import { primeSimulatorRoutes } from 'constants/routes'; const originSITValidationSchema = Yup.object().shape({ reason: Yup.string().required('Required'), @@ -37,9 +39,11 @@ const OriginSITServiceItemForm = ({ shipment, submission }) => { sitHHGActualOrigin: { streetAddress1: '', streetAddress2: '', + streetAddress3: '', city: '', state: '', postalCode: '', + county: '', }, }; @@ -54,26 +58,62 @@ const OriginSITServiceItemForm = ({ shipment, submission }) => { submission({ body }); }; + const { moveCodeOrID } = useParams(); + const navigate = useNavigate(); + const handleCancel = () => { + navigate(generatePath(primeSimulatorRoutes.VIEW_MOVE_PATH, { moveCodeOrID })); + }; + return ( -
- - - - - - - - - - - + {({ isValid, isSubmitting, handleSubmit, setValues }) => { + const handleLocationChange = (newValue) => { + setValues((prevValues) => { + return { + ...prevValues, + sitHHGActualOrigin: { + ...prevValues.address, + city: newValue.city, + state: newValue.state ? newValue.state : '', + county: newValue.county, + postalCode: newValue.postalCode, + usprcId: newValue.usPostRegionCitiesId ? newValue.usPostRegionCitiesId : '', + }, + }; + }); + }; + + return ( +
+ + + + + + + + + + + + + ); + }}
); }; From 780cbff9fbf9c6f8524a36061450d97156783287 Mon Sep 17 00:00:00 2001 From: Alex Lusk Date: Fri, 8 Nov 2024 00:36:36 +0000 Subject: [PATCH 02/38] Add zip city lookup to prime shipment creation Form --- .../Shipment/PrimeUIShipmentCreateForm.jsx | 96 +++++++++++++++++-- 1 file changed, 87 insertions(+), 9 deletions(-) diff --git a/src/pages/PrimeUI/Shipment/PrimeUIShipmentCreateForm.jsx b/src/pages/PrimeUI/Shipment/PrimeUIShipmentCreateForm.jsx index 907e77012e3..d4ada09fb1b 100644 --- a/src/pages/PrimeUI/Shipment/PrimeUIShipmentCreateForm.jsx +++ b/src/pages/PrimeUI/Shipment/PrimeUIShipmentCreateForm.jsx @@ -18,7 +18,7 @@ import { LOCATION_TYPES } from 'types/sitStatusShape'; const sitLocationOptions = dropdownInputOptions(LOCATION_TYPES); const PrimeUIShipmentCreateForm = () => { - const { values } = useFormikContext(); + const { values, setValues } = useFormikContext(); const { shipmentType } = values; const { sitExpected, hasProGear } = values.ppmShipment; const { hasTrailer } = values.boatShipment; @@ -100,6 +100,44 @@ const PrimeUIShipmentCreateForm = () => { shipmentTypeOptions = shipmentTypeOptions.filter((e) => e.key !== SHIPMENT_TYPES.MOBILE_HOME); } + const handleLocationChange = (key1, key2) => { + if (key1 && key2) { + return (newValue) => { + setValues((prevValues) => { + const newValues = { ...prevValues }; + newValues[key1][key2] = { + ...newValues[key1][key2], + city: newValue.city, + state: newValue.state ? newValue.state : '', + county: newValue.county, + postalCode: newValue.postalCode, + usprcId: newValue.usPostRegionCitiesId ? newValue.usPostRegionCitiesId : '', + }; + return newValues; + }); + }; + } + + if (key1) { + return (newValue) => { + setValues((prevValues) => { + const newValues = { ...prevValues }; + newValues[key1] = { + ...newValues[key1], + city: newValue.city, + state: newValue.state ? newValue.state : '', + county: newValue.county, + postalCode: newValue.postalCode, + usprcId: newValue.usPostRegionCitiesId ? newValue.usPostRegionCitiesId : '', + }; + return newValues; + }); + }; + } + + return () => {}; + }; + return (

Shipment Type

@@ -117,6 +155,8 @@ const PrimeUIShipmentCreateForm = () => { ( <>

What address are the movers picking up from?

@@ -153,7 +193,11 @@ const PrimeUIShipmentCreateForm = () => { {hasSecondaryPickupAddress === 'true' && ( <>
Second Pickup Address
- +

Third pickup location

@@ -189,7 +233,11 @@ const PrimeUIShipmentCreateForm = () => { {hasTertiaryPickupAddress === 'true' && hasSecondaryPickupAddress === 'true' && ( <>
Third Pickup Address
- + )} @@ -200,6 +248,8 @@ const PrimeUIShipmentCreateForm = () => { name="ppmShipment.destinationAddress" legend="Destination Address" address1LabelHint="Optional" + zipCityEnabled + handleLocationChange={handleLocationChange('ppmShipment', 'destinationAddress')} render={(fields) => ( <> {fields} @@ -235,7 +285,11 @@ const PrimeUIShipmentCreateForm = () => { {hasSecondaryDestinationAddress === 'true' && ( <>
Second Destination Address
- +

Third delivery location

@@ -271,7 +325,11 @@ const PrimeUIShipmentCreateForm = () => { {hasTertiaryDestinationAddress === 'true' && hasSecondaryDestinationAddress === 'true' && ( <>
Third Destination Address
- + )} @@ -392,6 +450,8 @@ const PrimeUIShipmentCreateForm = () => {
Pickup Address
( <> {fields} @@ -427,7 +487,11 @@ const PrimeUIShipmentCreateForm = () => { {hasSecondaryPickupAddress === 'true' && ( <>
Second Pickup Address
- +

Third pickup location

@@ -463,7 +527,11 @@ const PrimeUIShipmentCreateForm = () => { {hasTertiaryPickupAddress === 'true' && hasSecondaryPickupAddress === 'true' && ( <>
Third Pickup Address
- + )} @@ -474,6 +542,8 @@ const PrimeUIShipmentCreateForm = () => { ( <> {fields} @@ -510,7 +580,11 @@ const PrimeUIShipmentCreateForm = () => { {hasSecondaryDestinationAddress === 'true' && ( <>
Second Destination Address
- +

Third delivery location

@@ -546,7 +620,11 @@ const PrimeUIShipmentCreateForm = () => { {hasTertiaryDestinationAddress === 'true' && hasSecondaryDestinationAddress === 'true' && ( <>
Third Destination Address
- + )} From 3c2d688480dbdf9c7b242ba3c4781b63a17424cb Mon Sep 17 00:00:00 2001 From: Alex Lusk Date: Fri, 8 Nov 2024 00:37:16 +0000 Subject: [PATCH 03/38] Add zip city lookup to prime shipment update addresses form --- .../PrimeUIShipmentUpdateAddressForm.jsx | 56 +++++++++----- .../PrimeUIShipmentUpdateAddressForm.test.jsx | 74 ++++++++++++------- 2 files changed, 83 insertions(+), 47 deletions(-) diff --git a/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateAddressForm.jsx b/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateAddressForm.jsx index ec188502922..93a70dcaf2e 100644 --- a/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateAddressForm.jsx +++ b/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateAddressForm.jsx @@ -29,25 +29,43 @@ const PrimeUIShipmentUpdateAddressForm = ({ return ( - {({ isValid, isSubmitting, handleSubmit, errors }) => ( -
- 0 ? 1 : 0}> - -

{addressLocation}

- -
- -
-
- )} + {({ isValid, isSubmitting, handleSubmit, errors, setValues }) => { + const handleLocationChange = (newValue) => { + setValues((prevValues) => { + return { + ...prevValues, + address: { + ...prevValues.address, + city: newValue.city, + state: newValue.state ? newValue.state : '', + county: newValue.county, + postalCode: newValue.postalCode, + usprcId: newValue.usPostRegionCitiesId ? newValue.usPostRegionCitiesId : '', + }, + }; + }); + }; + + return ( +
+ 0 ? 1 : 0}> + +

{addressLocation}

+ +
+ +
+
+ ); + }}
); }; diff --git a/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateAddressForm.test.jsx b/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateAddressForm.test.jsx index 4276520e0d6..4f02cef5a10 100644 --- a/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateAddressForm.test.jsx +++ b/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateAddressForm.test.jsx @@ -23,9 +23,10 @@ describe('PrimeUIShipmentUpdateAddressForm', () => { id: 'c56a4180-65aa-42ec-a945-5fd21dec0538', streetAddress1: '444 Main Ave', streetAddress2: 'Apartment 9000', - streetAddress3: '', + streetAddress3: 'c/o Anyone', city: 'Anytown', state: 'AL', + county: 'Los Angeles', postalCode: '90210', country: 'USA', eTag: '1234567890', @@ -41,7 +42,15 @@ describe('PrimeUIShipmentUpdateAddressForm', () => { eTag: shipmentAddress.eTag, }; - const updatePickupAddressSchema = Yup.object().shape({ + const initialValuesDestinationAddress = { + addressID: shipmentAddress.id, + destinationAddress: { + address: reformatPrimeApiShipmentAddress, + }, + eTag: shipmentAddress.eTag, + }; + + const updateAddressSchema = Yup.object().shape({ addressID: Yup.string(), pickupAddress: Yup.object().shape({ address: requiredAddressSchema, @@ -63,7 +72,7 @@ describe('PrimeUIShipmentUpdateAddressForm', () => { renderWithProviders( { expect(screen.getByRole('heading', { name: 'Pickup address', level: 2 })).toBeInTheDocument(); expect(screen.getByLabelText(/Address 1/)).toBeInTheDocument(); expect(screen.getByLabelText(/Address 2/)).toBeInTheDocument(); + expect(screen.getByLabelText(/Address 3/)).toBeInTheDocument(); expect(screen.getByLabelText('City')).toBeInTheDocument(); + expect(screen.getByLabelText('City')).toHaveValue(shipmentAddress.city); + expect(screen.getByLabelText('County')).toBeInTheDocument(); + expect(screen.getByLabelText('County')).toHaveValue(shipmentAddress.county); expect(screen.getByLabelText('State')).toBeInTheDocument(); + expect(screen.getByLabelText('State')).toHaveValue(shipmentAddress.state); expect(screen.getByLabelText('ZIP')).toBeInTheDocument(); + expect(screen.getByLabelText('ZIP')).toHaveValue(shipmentAddress.postalCode); + expect(screen.getByRole('button', { name: 'Save' })).toBeEnabled(); }); @@ -82,7 +98,7 @@ describe('PrimeUIShipmentUpdateAddressForm', () => { renderWithProviders( { ); await userEvent.type(screen.getByLabelText(/Address 1/), '23 City Str'); - await userEvent.type(screen.getByLabelText('City'), 'City'); - await userEvent.clear(screen.getByLabelText('ZIP')); - await userEvent.type(screen.getByLabelText('ZIP'), '90210'); - await userEvent.selectOptions(screen.getByLabelText('State'), ['CA']); + await userEvent.type(screen.getByLabelText(/Address 2/), 'Apt 23'); + await userEvent.type(screen.getByLabelText(/Address 3/), 'C/O Twenty Three'); const submitBtn = screen.getByRole('button', { name: 'Save' }); await waitFor(() => { @@ -102,30 +116,35 @@ describe('PrimeUIShipmentUpdateAddressForm', () => { await userEvent.click(submitBtn); }); - it('disables the submit button when the zip is bad', async () => { + it('does not disable the submit button when address lines 2 or 3 are blank', async () => { renderWithProviders( , ); - await userEvent.clear(screen.getByLabelText('ZIP')); - await userEvent.type(screen.getByLabelText('ZIP'), '1'); - (await screen.getByLabelText('ZIP')).blur(); + + await userEvent.clear(screen.getByLabelText(/Address 3/)); + (await screen.getByLabelText(/Address 3/)).blur(); await waitFor(() => { - expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled(); - expect(screen.getByText('Must be valid zip code')).toBeInTheDocument(); + expect(screen.getByRole('button', { name: 'Save' }).getAttribute('disabled')).toBeFalsy(); + }); + + await userEvent.clear(screen.getByLabelText(/Address 2/)); + (await screen.getByLabelText(/Address 2/)).blur(); + await waitFor(() => { + expect(screen.getByRole('button', { name: 'Save' }).getAttribute('disabled')).toBeFalsy(); }); }); - it('disables the submit button when the address 1 is missing', async () => { + it('disables the submit button when the address 1 is missing - pickup', async () => { renderWithProviders( { }); }); - it('disables the submit button when city is missing', async () => { + it('disables the submit button when the address 1 is missing - desination', async () => { renderWithProviders( , ); - await userEvent.clear(screen.getByLabelText('City')); - (await screen.getByLabelText('City')).blur(); + await userEvent.clear(screen.getByLabelText(/Address 1/)); + (await screen.getByLabelText(/Address 1/)).blur(); await waitFor(() => { expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled(); - expect(screen.getByText('Required')).toBeInTheDocument(); }); }); }); From 83a606e9ce4b094b73b1fe9d8c1c57bcc21a5a99 Mon Sep 17 00:00:00 2001 From: Alex Lusk Date: Fri, 8 Nov 2024 00:40:25 +0000 Subject: [PATCH 04/38] Add zip city lookup to prime update PPM shipment form --- .../Shipment/PrimeUIShipmentUpdatePPMForm.jsx | 70 +++++++++++++++++-- .../PrimeUIShipmentUpdatePPMForm.test.jsx | 13 ++-- src/utils/formatters.js | 1 + 3 files changed, 74 insertions(+), 10 deletions(-) diff --git a/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdatePPMForm.jsx b/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdatePPMForm.jsx index 33286b9abfc..398bcc4d434 100644 --- a/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdatePPMForm.jsx +++ b/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdatePPMForm.jsx @@ -14,7 +14,7 @@ import MaskedTextField from 'components/form/fields/MaskedTextField/MaskedTextFi const sitLocationOptions = dropdownInputOptions(LOCATION_TYPES); const PrimeUIShipmentUpdatePPMForm = () => { - const { values } = useFormikContext(); + const { values, setValues } = useFormikContext(); const { sitExpected, hasProGear, @@ -24,6 +24,44 @@ const PrimeUIShipmentUpdatePPMForm = () => { hasTertiaryDestinationAddress, } = values.ppmShipment; + const handleLocationChange = (key1, key2) => { + if (key1 && key2) { + return (newValue) => { + setValues((prevValues) => { + const newValues = { ...prevValues }; + newValues[key1][key2] = { + ...newValues[key1][key2], + city: newValue.city, + state: newValue.state ? newValue.state : '', + county: newValue.county, + postalCode: newValue.postalCode, + usprcId: newValue.usPostRegionCitiesId ? newValue.usPostRegionCitiesId : '', + }; + return newValues; + }); + }; + } + + if (key1) { + return (newValue) => { + setValues((prevValues) => { + const newValues = { ...prevValues }; + newValues[key1] = { + ...newValues[key1], + city: newValue.city, + state: newValue.state ? newValue.state : '', + county: newValue.county, + postalCode: newValue.postalCode, + usprcId: newValue.usPostRegionCitiesId ? newValue.usPostRegionCitiesId : '', + }; + return newValues; + }); + }; + } + + return () => {}; + }; + return (

Dates

@@ -36,6 +74,8 @@ const PrimeUIShipmentUpdatePPMForm = () => { ( <>

What address are the movers picking up from?

@@ -71,7 +111,11 @@ const PrimeUIShipmentUpdatePPMForm = () => {
{hasSecondaryPickupAddress === 'true' && ( <> - +

Third pickup location

@@ -101,7 +145,13 @@ const PrimeUIShipmentUpdatePPMForm = () => { /> - {hasTertiaryPickupAddress === 'true' && } + {hasTertiaryPickupAddress === 'true' && ( + + )} )} @@ -112,6 +162,8 @@ const PrimeUIShipmentUpdatePPMForm = () => { name="ppmShipment.destinationAddress" legend="Destination Address" address1LabelHint="Optional" + zipCityEnabled + handleLocationChange={handleLocationChange('ppmShipment', 'destinationAddress')} render={(fields) => ( <> {fields} @@ -146,7 +198,11 @@ const PrimeUIShipmentUpdatePPMForm = () => { {hasSecondaryDestinationAddress === 'true' && ( <> - +

Third destination location

@@ -177,7 +233,11 @@ const PrimeUIShipmentUpdatePPMForm = () => { {hasTertiaryDestinationAddress === 'true' && ( - + )} )} diff --git a/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdatePPMForm.test.jsx b/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdatePPMForm.test.jsx index 2878c33af59..48e80768ade 100644 --- a/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdatePPMForm.test.jsx +++ b/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdatePPMForm.test.jsx @@ -4,6 +4,7 @@ import { Formik } from 'formik'; import PrimeUIShipmentUpdatePPMForm from 'pages/PrimeUI/Shipment/PrimeUIShipmentUpdatePPMForm'; import { formatCustomerDate } from 'utils/formatters'; +import { MockProviders } from 'testUtils'; const shipment = { actualPickupDate: null, @@ -157,11 +158,13 @@ const initialValues = { function renderShipmentUpdatePPMForm(props) { render( - -

- - - , + + +
+ + +
+
, ); } diff --git a/src/utils/formatters.js b/src/utils/formatters.js index 50b54459236..44ef42c7030 100644 --- a/src/utils/formatters.js +++ b/src/utils/formatters.js @@ -436,6 +436,7 @@ export function fromPrimeAPIAddressFormat(address) { streetAddress2: address.streetAddress2, streetAddress3: address.streetAddress3, city: address.city, + county: address.county, state: address.state, postalCode: address.postalCode, }; From 21cdfce4b9fe7336ea877c051a4b949606b215cb Mon Sep 17 00:00:00 2001 From: Alex Lusk Date: Fri, 8 Nov 2024 00:41:36 +0000 Subject: [PATCH 05/38] Add zip city lookup to prime update destination address form --- ...UIShipmentUpdateDestinationAddressForm.jsx | 104 +++++++++++------- ...pmentUpdateDestinationAddressForm.test.jsx | 43 +++----- 2 files changed, 77 insertions(+), 70 deletions(-) diff --git a/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateDestinationAddressForm.jsx b/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateDestinationAddressForm.jsx index 0b923d4aa14..3c7e906d4c3 100644 --- a/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateDestinationAddressForm.jsx +++ b/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateDestinationAddressForm.jsx @@ -27,50 +27,70 @@ const PrimeUIShipmentUpdateDestinationAddressForm = ({ return ( - {({ isValid, isSubmitting, handleSubmit, errors }) => ( -
- 0 ? 1 : 0}> - -

Update Shipment Destination Address

+ {({ isValid, isSubmitting, handleSubmit, errors, setValues }) => { + const handleLocationChange = (newValue) => { + setValues((prevValues) => { + return { + ...prevValues, + newAddress: { + address: { + ...prevValues.newAddress.address, + city: newValue.city, + state: newValue.state ? newValue.state : '', + county: newValue.county, + postalCode: newValue.postalCode, + usprcId: newValue.usPostRegionCitiesId ? newValue.usPostRegionCitiesId : '', + }, + }, + }; + }); + }; + + return ( + + 0 ? 1 : 0}> -
- This is used to update the destination address on an{' '} - already approved shipment.
- This also updates the final destination address for destination SIT service items in the shipment. -
-
- This endpoint should be used for changing the destination address of HHG & NTSR shipments. -
-
- The address update will be automatically approved unless it changes any of the following: -
- - - the service area
- - mileage bracket for direct delivery
- - domestic short haul to domestic line haul or vice versa
- SIT delivery out over 50 miles{' '} - or - back under 50 miles -
-
-
- If any of those change, the address change will require TOO approval. -
+

Update Shipment Destination Address

+ +
+ This is used to update the destination address on an{' '} + already approved shipment.
+ This also updates the final destination address for destination SIT service items in the shipment. +
+
+ This endpoint should be used for changing the destination address of HHG & NTSR shipments. +
+
+ The address update will be automatically approved unless it changes any of the following: +
+ + - the service area
+ - mileage bracket for direct delivery
+ - domestic short haul to domestic line haul or vice versa
- SIT delivery out over 50 miles{' '} + or + back under 50 miles +
+
+
+ If any of those change, the address change will require TOO approval. +
+
+ +
- - -
- -
-
- )} + +
+ + ); + }} ); }; diff --git a/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateDestinationAddressForm.test.jsx b/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateDestinationAddressForm.test.jsx index 800505921ed..a011c9224c6 100644 --- a/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateDestinationAddressForm.test.jsx +++ b/src/pages/PrimeUI/Shipment/PrimeUIShipmentUpdateDestinationAddressForm.test.jsx @@ -23,8 +23,9 @@ describe('PrimeUIShipmentUpdateDestinationAddressForm', () => { id: 'c56a4180-65aa-42ec-a945-5fd21dec0538', streetAddress1: '444 Main Ave', streetAddress2: 'Apartment 9000', - streetAddress3: '', + streetAddress3: 'J. Jonah Jameson', city: 'Anytown', + county: 'SOLANO', state: 'AL', postalCode: '90210', country: 'USA', @@ -89,10 +90,8 @@ describe('PrimeUIShipmentUpdateDestinationAddressForm', () => { ); await userEvent.type(screen.getByLabelText(/Address 1/), '23 City Str'); - await userEvent.type(screen.getByLabelText('City'), 'City'); - await userEvent.clear(screen.getByLabelText('ZIP')); - await userEvent.type(screen.getByLabelText('ZIP'), '90210'); - await userEvent.selectOptions(screen.getByLabelText('State'), ['CA']); + await userEvent.type(screen.getByLabelText(/Address 2/), 'Apt 23'); + await userEvent.type(screen.getByLabelText(/Address 3/), 'C/O Twenty Three'); await userEvent.type(screen.getByLabelText('Contractor Remarks'), 'Test remarks'); const submitBtn = screen.getByRole('button', { name: 'Save' }); @@ -102,24 +101,6 @@ describe('PrimeUIShipmentUpdateDestinationAddressForm', () => { await userEvent.click(submitBtn); }); - it('disables the submit button when the zip is bad', async () => { - renderWithProviders( - , - ); - await userEvent.clear(screen.getByLabelText('ZIP')); - await userEvent.type(screen.getByLabelText('ZIP'), '1'); - (await screen.getByLabelText('ZIP')).blur(); - await waitFor(() => { - expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled(); - expect(screen.getByText('Must be valid zip code')).toBeInTheDocument(); - }); - }); - it('disables the submit button when the address 1 is missing', async () => { renderWithProviders( { }); }); - it('disables the submit button when city is missing', async () => { + it('does not disable the submit button when address lines 2 or 3 are blank', async () => { renderWithProviders( { name="newAddress.address" />, ); - await userEvent.clear(screen.getByLabelText('City')); - (await screen.getByLabelText('City')).blur(); + + await userEvent.clear(screen.getByLabelText(/Address 3/)); + (await screen.getByLabelText(/Address 3/)).blur(); await waitFor(() => { - expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled(); - expect(screen.getByText('Required')).toBeInTheDocument(); + expect(screen.getByRole('button', { name: 'Save' }).getAttribute('disabled')).toBeFalsy(); + }); + + await userEvent.clear(screen.getByLabelText(/Address 2/)); + (await screen.getByLabelText(/Address 2/)).blur(); + await waitFor(() => { + expect(screen.getByRole('button', { name: 'Save' }).getAttribute('disabled')).toBeFalsy(); }); }); }); From 74d277af15b991c7c3c970399313e97f644b0326 Mon Sep 17 00:00:00 2001 From: Alex Lusk Date: Fri, 15 Nov 2024 18:53:57 +0000 Subject: [PATCH 06/38] update prime sim address fields to use new locationLookup paradigm --- .../OriginSITServiceItemForm.jsx | 22 +--- .../Shipment/PrimeUIShipmentCreateForm.jsx | 124 +++++++++--------- .../PrimeUIShipmentUpdateAddressForm.jsx | 20 +-- ...UIShipmentUpdateDestinationAddressForm.jsx | 22 +--- .../Shipment/PrimeUIShipmentUpdatePPMForm.jsx | 82 +++++------- 5 files changed, 99 insertions(+), 171 deletions(-) diff --git a/src/components/PrimeUI/CreateShipmentServiceItemForm/OriginSITServiceItemForm.jsx b/src/components/PrimeUI/CreateShipmentServiceItemForm/OriginSITServiceItemForm.jsx index c1dfb8c7012..dc86b6ad5e1 100644 --- a/src/components/PrimeUI/CreateShipmentServiceItemForm/OriginSITServiceItemForm.jsx +++ b/src/components/PrimeUI/CreateShipmentServiceItemForm/OriginSITServiceItemForm.jsx @@ -66,23 +66,7 @@ const OriginSITServiceItemForm = ({ shipment, submission }) => { return ( - {({ isValid, isSubmitting, handleSubmit, setValues }) => { - const handleLocationChange = (newValue) => { - setValues((prevValues) => { - return { - ...prevValues, - sitHHGActualOrigin: { - ...prevValues.address, - city: newValue.city, - state: newValue.state ? newValue.state : '', - county: newValue.county, - postalCode: newValue.postalCode, - usprcId: newValue.usPostRegionCitiesId ? newValue.usPostRegionCitiesId : '', - }, - }; - }); - }; - + {({ isValid, isSubmitting, handleSubmit, ...formikProps }) => { return (
@@ -102,8 +86,8 @@ const OriginSITServiceItemForm = ({ shipment, submission }) => {