Skip to content

Commit

Permalink
Add project selection
Browse files Browse the repository at this point in the history
This only includes projects that have RI-specific incentives, whether
from utilities or the state.
  • Loading branch information
oyamauchi committed Aug 15, 2023
1 parent bf717ac commit b2bf048
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
35 changes: 34 additions & 1 deletion src/calculator-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,53 @@ const HOUSEHOLD_SIZE_OPTIONS: OptionParam[] = [1, 2, 3, 4, 5, 6, 7, 8].map(
},
);

const PROJECT_OPTIONS: OptionParam[] = [
{ value: 'heat_pump_clothes_dryer', label: 'Clothes dryer' },
{
value: 'heat_pump_air_conditioner_heater',
label: 'Heating, ventilation & cooling',
},
{ value: 'new_electric_vehicle', label: 'New electric vehicle' },
{ value: 'rooftop_solar_installation', label: 'Rooftop solar installation' },
{ value: 'used_electric_vehicle', label: 'Used electric vehicle' },
{ value: 'heat_pump_water_heater', label: 'Water heater' },
{ value: 'weatherization', label: 'Weatherization' },
];

export const formTemplate = (
[
zip,
ownerStatus,
householdIncome,
taxFiling,
householdSize,
project,
utility,
]: Array<string>,
showProjectsField: boolean,
showUtilityField: boolean,
utilityOptions: OptionParam[],
onSubmit: (e: SubmitEvent) => void,
onZipChanged: (e: InputEvent) => void,
) => {
const projectsField = showProjectsField
? html` <div>
<label for="project">
Project
<sl-tooltip content="Which projects are you interested in?" hoist
>${questionIcon(18, 18)}</sl-tooltip
><br />
${select({
id: 'project',
required: true,
options: PROJECT_OPTIONS,
currentValue: project,
tabIndex: 0,
})}
</label>
</div>`
: nothing;

const utilityField = showUtilityField
? html`<div>
<label for="utility">
Expand Down Expand Up @@ -208,7 +241,7 @@ export const formTemplate = (
})}
</label>
</div>
${utilityField}
${projectsField} ${utilityField}
<div>
<button type="submit">Calculate! ${downIcon(18, 18)}</button>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export class RewiringAmericaCalculator extends LitElement {
this.householdSize,
],
false,
false,
[],
(event: SubmitEvent) => this.submit(event),
() => {},
Expand Down
12 changes: 11 additions & 1 deletion src/state-calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ export class RewiringAmericaStateCalculator extends LitElement {
@property({ type: String, attribute: 'household-size' })
householdSize: string = '1';

@property({ type: String, attribute: 'project' })
project: string = 'heat_pump_air_conditioner_heater';

@property({ type: String, attribute: 'utility' })
utility: string = '';

Expand All @@ -85,6 +88,7 @@ export class RewiringAmericaStateCalculator extends LitElement {
this.taxFiling = (formData.get('tax_filing') as FilingStatus) || '';
this.householdSize = (formData.get('household_size') as string) || '';
this.utility = (formData.get('utility') ?? '') as string;
this.project = (formData.get('project') ?? '') as string;
}

get hideResult() {
Expand All @@ -93,7 +97,8 @@ export class RewiringAmericaStateCalculator extends LitElement {
this.ownerStatus &&
this.taxFiling &&
this.householdIncome &&
this.householdSize
this.householdSize &&
this.project
);
}

Expand All @@ -106,6 +111,7 @@ export class RewiringAmericaStateCalculator extends LitElement {
household_income,
tax_filing,
household_size,
project,
utility,
]) => {
if (this.hideResult) {
Expand All @@ -118,6 +124,7 @@ export class RewiringAmericaStateCalculator extends LitElement {
household_income,
tax_filing,
household_size,
items: project,
});
query.append('authority_types', 'federal');
query.append('authority_types', 'state');
Expand All @@ -140,6 +147,7 @@ export class RewiringAmericaStateCalculator extends LitElement {
this.householdIncome,
this.taxFiling,
this.householdSize,
this.project,
this.utility,
],
});
Expand Down Expand Up @@ -182,9 +190,11 @@ export class RewiringAmericaStateCalculator extends LitElement {
this.householdIncome,
this.taxFiling,
this.householdSize,
this.project,
this.utility,
],
true,
true,
this._utilityOptionsTask.render({
initial: () => [BLANK_UTILITY],
pending: () => [BLANK_UTILITY],
Expand Down

0 comments on commit b2bf048

Please sign in to comment.