Skip to content

Commit

Permalink
Add feature to Update Pollution Values
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarshg6 committed May 6, 2021
1 parent 36b871b commit ac9438c
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Chart from "react-google-charts";
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCar, faTree } from '@fortawesome/free-solid-svg-icons';

import { Dropdown, Input, Header, Grid, Card, Label, Statistic } from 'semantic-ui-react';
import { Dropdown, Input, Header, Grid, Card, Label } from 'semantic-ui-react';

const transactionOptions = [
{
Expand Down Expand Up @@ -407,6 +407,33 @@ class ComponentIndex extends Component {
)
}

getGco2eValue() {
const { txType } = this.state

switch (txType) {
case 'nft-deploy':
return this.state.deployGCO2e
case 'nft-mint':
return this.state.mintGCO2e
case 'nft-transfer':
return this.state.transferGCO2e
default:
return 0
}
}

getCarPollutionValue() {
const factor = 0.1

return String(this.getGco2eValue() * factor)
}

getTreePollutionValue() {
const factor = 0.01

return String(this.getGco2eValue() * factor)
}

renderSecondHalf() {
return (
<Grid columns={2}>
Expand All @@ -425,8 +452,8 @@ class ComponentIndex extends Component {
/>
<Card.Content>
<Card.Header>
178 miles
</Card.Header>
{this.getCarPollutionValue() + ' miles'}
</Card.Header>
<Card.Description>
driven by a passenger car
</Card.Description>
Expand All @@ -442,8 +469,8 @@ class ComponentIndex extends Component {
/>
<Card.Content>
<Card.Header>
23
</Card.Header>
{this.getTreePollutionValue()}
</Card.Header>
<Card.Description>
fully grown trees
</Card.Description>
Expand Down

0 comments on commit ac9438c

Please sign in to comment.