Skip to content
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
25 changes: 24 additions & 1 deletion app/javascript/packages/address-search/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Requires @18f/identity-i18n.
To use this component, provide callbacks to it for desired behaviors.

```typescript jsx
import AddressSearch from '@18f/identity-address-search';
import FullAddressSearch from '@18f/identity-address-search';

// Render UI component

Expand All @@ -40,6 +40,29 @@ return(
);
```

By adding the usesErrorComponent prop to the FullAddressSearch component you can opt in to showing a specialized error message for skipping location selection when a locations endpoint error happens instead of the alert.

```typescript jsx
import FullAddressSearch from '@18f/identity-address-search';

// Render UI component

return(
<>
<FullAddressSearch
disabled={disabledAddressSearchCallback}
handleLocationSelect={handleLocationSelect}
locationsURL={LOCATIONS_URL}
noInPersonLocationsDisplay={noInPersonLocationsDisplay}
onFoundLocations={setLocationResultsCallback}
registerField={registerFieldCallback}
resultsHeaderComponent={resultsHeaderComponent}
usesErrorComponent
/>
</>
);
```

## License

This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function FullAddressSearchInput({
registerField = () => undefined,
usStatesTerritories,
uspsApiError,
usesErrorComponent,
}: FullAddressSearchInputProps) {
const { t } = useI18n();
const spinnerButtonRef = useRef<SpinnerButtonRefHandle>(null);
Expand Down Expand Up @@ -175,12 +176,12 @@ export default function FullAddressSearchInput({
isBig
ref={spinnerButtonRef}
type="submit"
onClick={uspsApiError ? handleContinue : handleSearch}
onClick={usesErrorComponent && uspsApiError ? handleContinue : handleSearch}
spinOnClick={false}
actionMessage={t('in_person_proofing.body.location.po_search.is_searching_message')}
longWaitDurationMs={1}
>
{uspsApiError
{usesErrorComponent && uspsApiError
? t('in_person_proofing.body.location.po_search.continue_button')
: t('in_person_proofing.body.location.po_search.search_button')}
</SpinnerButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function FullAddressSearch({
disabled={disabled}
locationsURL={locationsURL}
uspsApiError={apiError}
usesErrorComponent={usesErrorComponent}
/>
{usesErrorComponent && apiError && <SkipUspsFacilitiesApiErrorMessage />}
{locationResults && foundAddress && !isLoadingLocations && (
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/packages/address-search/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@18f/identity-address-search",
"version": "3.4.0",
"version": "4.0.1",
"type": "module",
"private": false,
"files": [
Expand Down Expand Up @@ -34,4 +34,4 @@
"directory": "app/javascript/packages/address-search"
},
"sideEffects": false
}
}
1 change: 1 addition & 0 deletions app/javascript/packages/address-search/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,5 @@ interface FullAddressSearchInputProps {
registerField?: RegisterFieldCallback;
usStatesTerritories: string[][];
uspsApiError: Error | null;
usesErrorComponent?: boolean;
}