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

LG-11082 - Add optional info alert to FullAddressSearch #9276

Conversation

gina-yamada
Copy link
Contributor

@gina-yamada gina-yamada commented Sep 27, 2023

🎫 Ticket

LG-11082 Refactor identity-site to use FullAddressSearch
Help Center Figma Mocks

  • This PR adds the optional info alert prop resultsHeaderComponent to FullAddressSearch so that the prop can be used in identity-site FullAddressSearch
  • This PR adds logic to FullAddressSearch and AddressSearch to show/hide Find a participating Post Office and You can verify your identity in person at a local participating United States Post Office. so we can show both on Login.gov and hide both in the Help Center when eithe search component is rendered

🛠 Summary of changes

  • Increased version of "@18f/identity-address-search from 3.0.0 to 3.1.0
  • Add additional handleLocationSelect optional prop to FullAddressSearch and passed it into InPersonLocations
  • Created a FullAddressSearchProps interface list
  • Renamed the interface used by FullAddressSearchInput to include Input to avoid duplicate prop interface name along with alphabetized the arg list
  • Added logic to FullAddressSearch and AddressSearch to only display the Page Header and PO Search About Text when handleLocationsSelect is not null.

📜 Testing Plan

  • Step 1: Running the application locally, enter the in-person proofing flow and confirm that the location results display as expected, specifically that no info alert displays, and that the "Select a Post Office..." message displays, along with the Select button for each post office returned in the list. This will be the view/flow from Login.gov

  • Step 2: This will be the view/flow from the Help Center. Edit app/javascript/packages/document-capture/components/in-person-location-full-address-entry-post-office-search-step.tsx.

  • Add the Alert import near the top of the file, update the arg for handleLocationSelect to be null, pass in the resultsHeaderComponent prop and component to FullAddressSearch (See code snipped below 👇 )

import { Alert } from '@18f/identity-components';


<FullAddressSearch
   registerField={registerField}
   onFoundLocations={setLocationResults}
   disabled={disabledAddressSearch}
   locationsURL={locationsURL}
   handleLocationSelect={null} // <--- CHANGE ME TOO <--- CHANGE ME TOO <--- CHANGE ME TOO
   usStatesTerritories={usStatesTerritories}
   resultsHeaderComponent={() => ( // <--- ADD ME START <--- ADD ME START <--- ADD ME START
      <Alert type="info" className="margin-bottom-4">
         <strong>You must start this process on Login.gov before going to the Post Office.</strong>
         <a href="https://login.gov">Learn more about verifying your identity in person.</a>
      </Alert>
   )} // <--- ADD ME END <--- ADD ME END <--- ADD ME END
/>

👀 Screenshots

If relevant, include a screenshot or screen capture of the changes.

no changes

Ensure all behavior is working as you'd expect for Login.gov

  • showing Find a participating Post Office
  • showing You can verify your identity in person at a local participating United States Post Office.
  • not showing info alert
  • showing Select a Post.... message
  • showing Select buttons on PO list

Screenshot 2023-09-28 at 10 07 10 AM

PO Help Center (with no logic to Hide Header and PO Search About Text)

This is what Help Center looks like currently when using FullAddressSearch (not the version in this PR)

Screenshot 2023-09-28 at 10 18 55 AM

showing info alert and no "Select" messages or buttons (English)

Ensure all behavior is working as you'd expect (to be used in the Help Center)

  • not showing Find a participating Post Office
  • not showing You can verify your identity in person at a local participating United States Post Office.
  • showing info alert
  • not showing Select a Post.... message
  • not showing Select buttons on PO list

Screenshot 2023-09-28 at 10 13 30 AM

<PageHeading>{t('in_person_proofing.headings.po_search.location')}</PageHeading>
<p>{t('in_person_proofing.body.location.po_search.po_search_about')}</p>
</>
)}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although we are not using AddressSearch at the moment, we will be. I wanted to update this component to have the same logic as FullAddressSearch so they behave similar. That will make switching over easier

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good if this change was covered with a spec, but probably of limited value until we get this back into use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added tests around this show/hide logic with commit d3f6b40

@@ -21,9 +71,9 @@ describe('FullAddressSearch', () => {
usStatesTerritories={usStatesTerritories}
onFoundLocations={handleLocationsFound}
locationsURL={locationsURL}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created interface FullAddressSearchProps and as a result had to update these tests to satisfy the data type- that is the reason for the following updates in this test file

<PageHeading>{t('in_person_proofing.headings.po_search.location')}</PageHeading>
<p>{t('in_person_proofing.body.location.po_search.po_search_about')}</p>
</>
)}
Copy link
Contributor Author

@gina-yamada gina-yamada Sep 28, 2023

Choose a reason for hiding this comment

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

I added logic to display/not display PageHeader and the PO Search About text. This logic is needed because we do not want to display both when this component is used in the Help Center, see the stuff in red. handleLoctionSelect is being used to display/not display the Select buttons on the PO list.

Screenshot 2023-09-27 at 1 09 36 PM

noInPersonLocationsDisplay: ComponentType<{ address: string }>;
resultsHeaderComponent?: ComponentType;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like we had the InPersonLocationsProps interface in both types.d and in in-person-locations.tsx. I deleted this one and updated the one in types.d to have the complete prop list.

@@ -1,6 +1,6 @@
{
"name": "@18f/identity-address-search",
"version": "3.0.0",
"version": "3.1.0",
"type": "module",
"private": false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

My changes should not be breaking so I went with a minor update. Please confirm you agree, not breaking.

…82-UpdateFullAddressSearchWithResultsHeaderComponent
@gina-yamada gina-yamada marked this pull request as ready for review September 28, 2023 19:34
Copy link
Contributor

@NavaTim NavaTim left a comment

Choose a reason for hiding this comment

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

My comments are non-blocking since they pertain to minor code quality issues, but I highly recommend implementing the suggested changes before merging.

locationsURL: string;
usStatesTerritories: [string, string][];
registerField?: RegisterFieldCallback;
usStatesTerritories: Array<Array<string>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we're making the type of usStatesTerritories less specific? In cases like this, where the string at index zero and index one have specific meaning (abbreviation vs name), using the stricter type can be helpful in ensuring that the value is correctly used.

Copy link
Contributor Author

@gina-yamada gina-yamada Sep 29, 2023

Choose a reason for hiding this comment

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

@NavaTim I modified this value as I was getting errors with newly created props on FullAddressSearch. I am not able to resolve errors with this data type but was able to with string[][].

I had to change it for FullAddressSearchProps for usStateTerritories as well. Perhaps we can jump on a call if you have availability if you still think I should stick with [string, string][].

Comment on lines 94 to 103
interface FullAddressSearchProps {
disabled: boolean;
handleLocationSelect: ((e: any, id: number) => Promise<void>) | null | undefined;
locationsURL: string;
noInPersonLocationsDisplay?: ComponentType<{ address: string }>;
onFoundLocations: Dispatch<SetStateAction<FormattedLocation[] | null | undefined>>;
registerField: RegisterFieldCallback;
resultsHeaderComponent?: ComponentType;
usStatesTerritories: Array<Array<string>>;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a good use case for extending types since many of the properties are shared between these components.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a great idea!

I looked into using this with FullAddressSearchProps - with AddressSearchProps as the extend but there is a prop on AddressSearchProps not needed by FullAddressSearchProp. I can create a third prop category and then extend it for both AddressSearchProp and FullAddressSearchProp listing only the unique props needed but think although nearly duplicate, keeping it as is might be best for readability and if we decide to remove on or the other down the road keeps it separate. Same with FullAddressSearchInputProps (extending FullAddressSearchProps).

<PageHeading>{t('in_person_proofing.headings.po_search.location')}</PageHeading>
<p>{t('in_person_proofing.body.location.po_search.po_search_about')}</p>
</>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good if this change was covered with a spec, but probably of limited value until we get this back into use.

@gina-yamada gina-yamada merged commit d32eb9f into main Sep 29, 2023
@gina-yamada gina-yamada deleted the yamada/LG-11082-UpdateFullAddressSearchWithResultsHeaderComponent branch September 29, 2023 20:19
@gina-yamada
Copy link
Contributor Author

Published to npm shortly after merging branch into main

@jmhooper jmhooper mentioned this pull request Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants