Skip to content

Commit

Permalink
Add "other" option to utility selector
Browse files Browse the repository at this point in the history
## Description

Because we can't be sure that the API's set of utilities is 100%
comprehensive, or that its location-to-utilities mapping is 100%
correct, we should have an escape hatch, so users don't have to give
an answer they know is incorrect.

The "other" value is not submitted to the API because it's not a valid
utility ID and the API would thus error. I'm pretty confident that's
sensible behavior for the API, so I'd rather not change it. We'll be
able to tell when someone chose "other" in API logs, when (a) the
utility param is absent in the /calculator request, while (b) the zip
is in a launched state. Since it's hard to know if a zip is in a
launched state when you're just looking at API logs, we may want to
explicitly record zips submitted with an "other" utility somewhere; if
so, we can do that as a followup.

I'm not sure about this Spanish translation. It's "otra" (feminine)
because it's referring to the feminine noun "empresa" (company), which
is part of the translation of "electric utility". Anyone who knows
Spanish better than I do (i.e. most people), feel free to correct me.

https://app.asana.com/0/1206661332626418/1206700057950880

## Test Plan

On a fresh page load, make sure the utility dropdown is not
clickable.

Enter a zip in a launched state (02861); make sure utilities load, the
first one is selected, and the "Other" entry is present. Submit the
form with a real utility selected and make sure its incentives come
up. Choose "Other", submit the form, and make sure no utility
incentives come up, but state and federal ones do.

Enter a zip in a non-launched state (76104); make sure utilities load,
and "Other" is the only option.

Enter an invalid zip (00000) and make sure the utility dropdown is not
clickable and you see the error message below the field.
  • Loading branch information
oyamauchi committed Mar 20, 2024
1 parent 52ee91d commit 60dc90e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/i18n/strings/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export const templates = {
sc373af4c1a974b57: `Cocina`,
sc5b20cb72269bc4f: `Los propietarios y inquilinos califican para diferentes incentivos.`,
sc997cfdf24ba9b58: `Aún no tenemos datos sobre las empresas de servicios eléctricos en su área.`,
sc9e494c8346b7cb5: `Otra`,
scb043c067bac571c: `Misisipi`,
scc21fdd8a2feaeef: `Georgia`,
scc3ef5dd3649b934: `Nuevo México`,
Expand Down
13 changes: 7 additions & 6 deletions src/state-calculator-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const HOUSEHOLD_SIZE_OPTIONS: (
value: count,
}));

const OTHER_UTILITY_ID = 'other';

const renderUtilityField = (
utility: string,
setUtility: (newValue: string) => void,
Expand All @@ -47,10 +49,9 @@ const renderUtilityField = (
) => {
const options: Option<string>[] =
utilitiesFetch.state === 'complete'
? Object.entries(utilitiesFetch.response.utilities).map(([id, info]) => ({
value: id,
label: info.name,
}))
? Object.entries(utilitiesFetch.response.utilities)
.map(([id, info]) => ({ value: id, label: info.name }))
.concat([{ value: OTHER_UTILITY_ID, label: msg('Other') }])
: [];

const enterZipToSelect = msg('Enter your ZIP code to select a utility.');
Expand Down Expand Up @@ -221,7 +222,7 @@ export const CalculatorForm: FC<{
setUtility(keys[0]);
}
} else {
setUtility('');
setUtility(OTHER_UTILITY_ID);
}
})
.catch(exc =>
Expand All @@ -239,7 +240,7 @@ export const CalculatorForm: FC<{
householdIncome,
householdSize,
taxFiling,
utility,
utility: utility !== OTHER_UTILITY_ID ? utility : '',
projects,
email,
});
Expand Down
4 changes: 4 additions & 0 deletions translations/es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,10 @@
<note from="lit-localize">followed by authority logos</note>
<target>Presentado en colaboración con</target>
</trans-unit>
<trans-unit id="sc9e494c8346b7cb5">
<source>Other</source>
<target>Otra</target>
</trans-unit>
</body>
</file>
</xliff>

0 comments on commit 60dc90e

Please sign in to comment.