Skip to content

Commit

Permalink
Remove state attribute for now
Browse files Browse the repository at this point in the history
  • Loading branch information
oyamauchi committed Sep 29, 2023
1 parent dbe35ec commit 4a4b94a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
1 change: 0 additions & 1 deletion src/rhode-island.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
<h1>Rewiring America Incentives Calculator</h1>
<rewiring-america-state-calculator
api-key="{{ apiKey }}"
state="RI"
household-income="80000"
household-size="1"
tax-filing="single"
Expand Down
29 changes: 1 addition & 28 deletions src/state-calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,6 @@ export class RewiringAmericaStateCalculator extends LitElement {
@property({ type: String, attribute: 'api-host' })
apiHost: string = DEFAULT_CALCULATOR_API_HOST;

/**
* Property to customize the calculator for a particular state. Must be the
* two-letter code, uppercase (example: "NY").
*
* Currently the only customization is to display the name of the state.
* TODO: Have a nice error message if you enter a zip/address outside this
* state, if it's defined.
*/
@property({ type: String, attribute: 'state' })
state: string = '';

/* supported properties to allow pre-filling the form */

@property({ type: String, attribute: 'zip' })
Expand Down Expand Up @@ -219,28 +208,12 @@ export class RewiringAmericaStateCalculator extends LitElement {
query.set('utility', this.utility);
}

const response = await fetchApi<APIResponse>(
return fetchApi<APIResponse>(
this.apiKey,
this.apiHost,
'/api/v1/calculator',
query,
);

// If the "state" attribute is set, enforce that some other state's
// incentives aren't shown. But if coverage.state is null, we won't show
// the error: we'll only be showing federal incentives in that case.
if (
this.state &&
response.coverage.state &&
response.coverage.state !== this.state
) {
// Throw to put the task into the ERROR state for rendering.
throw new Error(
`That ZIP code is not in ${STATES[this.state]?.name ?? this.state}.`,
);
}

return response;
},
onComplete: () => {
this.tempState = null;
Expand Down

0 comments on commit 4a4b94a

Please sign in to comment.