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

Handle multi-item incentives, and more items #158

Merged
merged 3 commits into from
May 7, 2024
Merged

Conversation

oyamauchi
Copy link
Member

@oyamauchi oyamauchi commented May 2, 2024

Description

This adds human-friendly labels for all the new items, plus labels for
a few specific groups of items. (E.g. an incentive for both
ducted_heat_pump and ductless_heat_pump will be shown as being for
"an air-source heat pump".)

I factored out the name logic into a new file because it's getting
pretty extensive.

The Spanish translations are taken from existing translations of
incentive descriptions (which, helpfully, serves to validate that all
the new items exist in incentives we already have). So I can't fully
vouch for them myself, but they are sourced from our human-vetted
translations.

Test Plan

Cypress tests pass. New unit test for names of multi-item incentives.

Manual testing of a few queries. The results should still match prod
exactly because none of the new items are used in the backend yet.
(The exception is the non-HP dryers and water heaters -- those are
already being used in the backend so will newly show up in the
frontend with this PR. Looked at those in English and Spanish to make
sure the headline looks good. ZIPs 81130 + Gunnison County Electric
and 81004 + San Isabel Electric)

## Description

This adds human-friendly labels for all the new items, plus labels for
a few specific groups of items. (E.g. an incentive for both
`ducted_heat_pump` and `ductless_heat_pump` will be shown as being for
"an air-source heat pump".)

I factored out the name logic into a new file because it's getting
pretty extensive.

The Spanish translations are taken from existing translations of
incentive descriptions (which, helpfully, serves to validate that all
the new items exist in incentives we already have). So I can't fully
vouch for them myself, but they are sourced from our human-vetted
translations.

## Test Plan

Cypress tests pass. New unit test for names of multi-item incentives.

Manual testing of a few queries. The results should still match prod
exactly because none of the new items are used in the backend yet.
(The exception is the non-HP dryers and water heaters -- those are
already being used in the backend so will newly show up in the
frontend with this PR. Looked at those in English and Spanish to make
sure the headline looks good.)
Copy link

vercel bot commented May 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
embed-rewiringamerica-org ✅ Ready (Inspect) Visit Preview May 7, 2024 10:40pm

Copy link
Contributor

@matelau matelau left a comment

Choose a reason for hiding this comment

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

I had one suggested improvement to item-name and a question, but otherwise LGTM!

src/item-name.ts Outdated Show resolved Hide resolved
test/item-names.test.ts Show resolved Hide resolved
@oyamauchi oyamauchi merged commit 6438117 into main May 7, 2024
3 checks passed
@oyamauchi oyamauchi deleted the owen.more-items branch May 7, 2024 22:46
oyamauchi added a commit that referenced this pull request May 9, 2024
## Description

In #158 I changed the constants that identify projects. I didn't
realize this would break the calculator for users who had the old
constants in local storage (as saved form values).

This is the simplest solution: change the local storage key for saved
form values, which will effectively clear the stored values for
everyone, one time.

There's no attempt to migrate the old values. We would have to support
that code indefinitely (unless we eventually cleared storage anyway),
and I don't think there's a ton of value in preserving form prefills.

The old key will still be there in users' local storage; if we want,
we can follow up with a change to delete it.

## Test Plan

Before making this change, reproed the problem by manually editing
local storage and changing the `RA-calc-form-values` value to have the
old constant `heat_pump_clothes_dryer` in the `projects` field. Submit
the form and make sure there was an error (trying to read `shortLabel`
of `undefined`).

Apply this change, make sure the form is reset to defaults, and
submitting it doesn't cause an error, and results show up.
oyamauchi added a commit that referenced this pull request May 9, 2024
## Description

In #158 I changed the constants that identify projects. I didn't
realize this would break the calculator for users who had the old
constants in local storage (as saved form values).

This is the simplest solution: change the local storage key for saved
form values, which will effectively clear the stored values for
everyone, one time.

There's no attempt to migrate the old values. We would have to support
that code indefinitely (unless we eventually cleared storage anyway),
and I don't think there's a ton of value in preserving form prefills.

The old key will still be there in users' local storage; if we want,
we can follow up with a change to delete it.

## Test Plan

Before making this change, reproed the problem by manually editing
local storage and changing the `RA-calc-form-values` value to have the
old constant `heat_pump_clothes_dryer` in the `projects` field. Submit
the form and make sure there was an error (trying to read `shortLabel`
of `undefined`).

Apply this change, make sure the form is reset to defaults, and
submitting it doesn't cause an error, and results show up.
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