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

B 22493 int - clear addr fields when toggle to No #14979

Draft
wants to merge 25 commits into
base: integrationTesting
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
59f0b92
Update TableQueue.jsx
loganwc Feb 24, 2025
752d8e6
initial commits
pambecker Feb 24, 2025
c7bce7d
Merge branch 'B-22301-main' into B-22493-clear-addr-fields
pambecker Feb 24, 2025
b925b37
minor adjustments
loganwc Feb 24, 2025
1839910
updates with main conflicts
pambecker Feb 25, 2025
e1a0843
Merge branch 'main' into B-22493-clear-addr-fields
pambecker Feb 25, 2025
9e311ae
cleanup
pambecker Feb 25, 2025
710b01c
Merge branch 'main' into B-22493-clear-addr-fields
pambecker Feb 26, 2025
f96b7fa
tests
pambecker Feb 28, 2025
eaf2cee
Merge branch 'main' into B-22493-clear-addr-fields
pambecker Feb 28, 2025
93de1e2
Merge branch 'main' into B-22493-clear-addr-fields
pambecker Mar 3, 2025
706f420
tests
pambecker Mar 4, 2025
4c020a0
tests
pambecker Mar 4, 2025
57d5a12
still testing
pambecker Mar 5, 2025
edce164
Merge branch 'main' into B-21348-Bulk-Assignment-Save
loganwc Mar 5, 2025
ec41739
bs linter not linting the lint
loganwc Mar 5, 2025
6d86e16
merge main
loganwc Mar 5, 2025
0aef1d2
fix tests
pambecker Mar 5, 2025
70d7b2f
cleanup
pambecker Mar 5, 2025
37f0ced
Merge branch 'main' into B-22493-clear-addr-fields
pambecker Mar 5, 2025
3866cf8
Merge branch 'main' into B-21348-Bulk-Assignment-Save
paulstonebraker Mar 6, 2025
f3a76a3
Merge branch 'main' into B-21348-Bulk-Assignment-Save
pambecker Mar 6, 2025
af96394
Merge pull request #14657 from transcom/B-21348-Bulk-Assignment-Save
pambecker Mar 6, 2025
9118de3
Merge branch 'main' into B-22493-clear-addr-fields
pambecker Mar 6, 2025
b253977
Merge branch 'B-22493-clear-addr-fields' into B-22493-INT
pambecker Mar 7, 2025
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
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export FEATURE_FLAG_SAFETY_MOVE=true
export FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=true

# Feature flags to enable third address
export FEATURE_FLAG_THIRD_ADDRESS_AVAILABLE=false
export FEATURE_FLAG_THIRD_ADDRESS_AVAILABLE=true
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need the green light from @deandreJones on this

Copy link
Contributor

Choose a reason for hiding this comment

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

If it is not on in prod, then it should not be on here

Copy link
Contributor Author

@pambecker pambecker Mar 7, 2025

Choose a reason for hiding this comment

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

hmmm....we've had other flags that were turned on right away from creation. I see Boat, Mobile Home, Safety, Queue management, Bulk assignment all as True and none of those are on in prod. I just felt like we had this FF long enough to know any true issues, and I find myself having to change this one constantly lately. Not sure what the rule is but will check

Copy link
Contributor

Choose a reason for hiding this comment

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

Well looks like those changes have been pushed under our noses. I'm just telling you what @deandreJones has said in the past

Copy link
Contributor

Choose a reason for hiding this comment

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

this file should reflect the current state of prod
so that when a dev starts work- they are working with the current state that is prod

you always have the option to use a .envrc.local file to override the values here


# Feature flag to disable/enable headquarters role
export FEATURE_FLAG_HEADQUARTERS_ROLE=true
Expand Down
109 changes: 109 additions & 0 deletions src/components/Customer/MtoShipmentForm/MtoShipmentForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const blankAddress = {
address: {
streetAddress1: '',
streetAddress2: '',
streetAddress3: '',
city: '',
state: '',
postalCode: '',
Expand Down Expand Up @@ -252,6 +253,104 @@ class MtoShipmentForm extends Component {
});
}
};
const handleAddressToggleChange = (e) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

move this into a helper function and call it from all the places you're doing this please

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe you could refactor to something like this

const updateAddressToggle = (fieldName, value, fieldKey, blankValue) => {
  setValues((prevValues) => ({
    ...prevValues,
    [fieldName]: value,
    [fieldKey]: value === 'false' ? blankValue : { ...prevValues[fieldKey] },
  }));
};

const handleAddressToggleChange = (e) => {
  const { name, value } = e.target;

  const fieldMap = {
    hasSecondaryPickup: { key: 'secondaryPickup', blankValue: { blankAddress } },
    hasTertiaryPickup: { key: 'tertiaryPickup', blankValue: { blankAddress } },
    hasDeliveryAddress: { key: 'delivery', blankValue: { ...values.delivery, address: newDutyLocationAddress } },
    hasSecondaryDelivery: { key: 'secondaryDelivery', blankValue: { blankAddress } },
    hasTertiaryDelivery: { key: 'tertiaryDelivery', blankValue: { blankAddress } },
  };

  if (fieldMap[name]) {
    updateAddressToggle(name, value, fieldMap[name].key, fieldMap[name].blankValue);
  }
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I actually meant to go back and figure out something for this, but got held up on tests for so long, forgot about it.

if (e.target.name === 'hasSecondaryPickup') {
if (e.target.value === 'false') {
setValues({
...values,
hasSecondaryPickup: 'false',
secondaryPickup: {
blankAddress,
},
});
} else if (e.target.value === 'true') {
setValues({
...values,
hasSecondaryPickup: 'true',
secondaryPickup: {
...values.secondaryPickup,
},
});
}
}
if (e.target.name === 'hasTertiaryPickup') {
if (e.target.value === 'false') {
setValues({
...values,
hasTertiaryPickup: 'false',
tertiaryPickup: {
blankAddress,
},
});
} else if (e.target.value === 'true') {
setValues({
...values,
hasTertiaryPickup: 'true',
tertiaryPickup: {
...values.tertiaryPickup,
},
});
}
}
if (e.target.name === 'hasDeliveryAddress') {
if (e.target.value === 'false') {
setValues({
...values,
hasDeliveryAddress: 'false',
delivery: {
...values.delivery,
address: newDutyLocationAddress,
},
});
} else if (e.target.value === 'true') {
setValues({
...values,
hasDeliveryAddress: 'true',
delivery: {
...values.delivery,
},
});
}
}
if (e.target.name === 'hasSecondaryDelivery') {
if (e.target.value === 'false') {
setValues({
...values,
hasSecondaryDelivery: 'false',
secondaryDelivery: {
blankAddress,
},
});
} else if (e.target.value === 'true') {
setValues({
...values,
hasSecondaryDelivery: 'true',
secondaryDelivery: {
...values.secondaryDelivery,
},
});
}
}
if (e.target.name === 'hasTertiaryDelivery') {
if (e.target.value === 'false') {
setValues({
...values,
hasTertiaryDelivery: 'false',
tertiaryDelivery: {
blankAddress,
},
});
} else if (e.target.value === 'true') {
setValues({
...values,
hasTertiaryDelivery: 'true',
tertiaryDelivery: {
...values.tertiaryDelivery,
},
});
}
}
};

const [isPreferredPickupDateAlertVisible, setIsPreferredPickupDateAlertVisible] = useState(false);
const [isPreferredDeliveryDateAlertVisible, setIsPreferredDeliveryDateAlertVisible] = useState(false);
Expand Down Expand Up @@ -384,6 +483,7 @@ class MtoShipmentForm extends Component {
title="Yes, I have a second pickup address"
checked={hasSecondaryPickup === 'true'}
disabled={!isPreceedingAddressComplete('true', values.pickup.address)}
onChange={handleAddressToggleChange}
/>
<Field
as={Radio}
Expand All @@ -395,6 +495,7 @@ class MtoShipmentForm extends Component {
title="No, I do not have a second pickup address"
checked={hasSecondaryPickup !== 'true'}
disabled={!isPreceedingAddressComplete('true', values.pickup.address)}
onChange={handleAddressToggleChange}
/>
</div>
</FormGroup>
Expand Down Expand Up @@ -426,6 +527,7 @@ class MtoShipmentForm extends Component {
values.secondaryPickup.address,
)
}
onChange={handleAddressToggleChange}
/>
<Field
as={Radio}
Expand All @@ -442,6 +544,7 @@ class MtoShipmentForm extends Component {
values.secondaryPickup.address,
)
}
onChange={handleAddressToggleChange}
/>
</div>
</FormGroup>
Expand Down Expand Up @@ -514,6 +617,7 @@ class MtoShipmentForm extends Component {
value="true"
title="Yes, I know my delivery address"
checked={hasDeliveryAddress === 'true'}
onChange={handleAddressToggleChange}
/>
<Field
as={Radio}
Expand All @@ -523,6 +627,7 @@ class MtoShipmentForm extends Component {
value="false"
title="No, I do not know my delivery address"
checked={hasDeliveryAddress === 'false'}
onChange={handleAddressToggleChange}
/>
</div>
</FormGroup>
Expand Down Expand Up @@ -553,6 +658,7 @@ class MtoShipmentForm extends Component {
title="Yes, I have a second delivery address"
checked={hasSecondaryDelivery === 'true'}
disabled={!isPreceedingAddressComplete('true', values.delivery.address)}
onChange={handleAddressToggleChange}
/>
<Field
as={Radio}
Expand All @@ -564,6 +670,7 @@ class MtoShipmentForm extends Component {
title="No, I do not have a second delivery address"
checked={hasSecondaryDelivery === 'false'}
disabled={!isPreceedingAddressComplete('true', values.delivery.address)}
onChange={handleAddressToggleChange}
/>
</div>
</FormGroup>
Expand Down Expand Up @@ -595,6 +702,7 @@ class MtoShipmentForm extends Component {
values.secondaryDelivery.address,
)
}
onChange={handleAddressToggleChange}
/>
<Field
as={Radio}
Expand All @@ -611,6 +719,7 @@ class MtoShipmentForm extends Component {
values.secondaryDelivery.address,
)
}
onChange={handleAddressToggleChange}
/>
</div>
</FormGroup>
Expand Down
Loading
Loading