Skip to content

Commit

Permalink
Incentive-type chips instead of separate sections
Browse files Browse the repository at this point in the history
  • Loading branch information
oyamauchi committed Aug 10, 2023
1 parent ab26d95 commit f09e9df
Showing 1 changed file with 34 additions and 16 deletions.
50 changes: 34 additions & 16 deletions src/state-incentive-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ export const stateIncentivesStyles = css`
border: 1px solid rgb(240, 240, 240);
}
.incentive__type-chip {
margin-bottom: 1em;
}
.incentive__type-chip span {
background-color: rgb(240, 237, 247);
border-radius: 3px;
font-weight: bold;
font-size: 0.8em;
padding: 0.3em 1em 0.3em 1em;
}
.incentive__title {
font-weight: bold;
}
Expand Down Expand Up @@ -56,8 +68,22 @@ const amountTemplate = (amount: Amount) =>
: `$${amount.number.toLocaleString()} per ${amount.unit}`
: nothing;

const formatIncentiveType = (incentive: Incentive) =>
incentive.type === 'tax_credit'
? 'TAX CREDIT'
: incentive.amount.type === 'dollar_amount'
? 'FLAT-RATE REBATE'
: incentive.amount.type === 'percent'
? 'COST REBATE'
: incentive.amount.type === 'dollars_per_unit'
? 'CAPACITY REBATE'
: 'REBATE';

const incentiveBoxTemplate = (incentive: Incentive) => html`
<div class="incentive ${incentive.eligible ? '' : 'incentive--dimmed'}">
<div class="incentive__type-chip">
<span> ${formatIncentiveType(incentive)}</span>
</div>
<div class="incentive__title">
${incentive.authority_name
? html`${incentive.authority_name}<br />`
Expand All @@ -81,19 +107,11 @@ const gridTemplate = (incentives: Incentive[]) => html` <div class="grid-3-2">
</div>`;

export const stateIncentivesTemplate = (response: APIResponse) =>
html` ${response.pos_rebate_incentives.length > 0
? html` <div class="card">
<h1 class="card__heading">Rebates</h1>
<div class="card-content">
${gridTemplate(response.pos_rebate_incentives)}
</div>
</div>`
: nothing}
${response.tax_credit_incentives.length > 0
? html` <div class="card">
<h1 class="card__heading">Tax Credits</h1>
<div class="card-content">
${gridTemplate(response.tax_credit_incentives)}
</div>
</div>`
: nothing}`;
html` <div class="card">
<div class="card-content">
${gridTemplate([
...response.pos_rebate_incentives,
...response.tax_credit_incentives,
])}
</div>
</div>`;

0 comments on commit f09e9df

Please sign in to comment.