Skip to content

Commit

Permalink
init clean zipcode page
Browse files Browse the repository at this point in the history
  • Loading branch information
rgraue committed Apr 16, 2024
1 parent 8071a43 commit 7c902f2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zwell-calc",
"version": "0.1.0",
"proxy": "http://localhost:3000",
"proxy": "https://app.zwell.io/",
"private": true,
"dependencies": {
"@emotion/react": "^11.11.3",
Expand Down
37 changes: 19 additions & 18 deletions src/components/Location/ZipDataComponent/zipdata.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,56 @@ const Zipdata = ({ zipcode }) => {
return false;
} else {
const convertedState = convertZipToState(zipcode);
return getState(convertedState.long).then(({ breakdown }) => {
return getState(convertedState).then(({ breakdown }) => {
// get find percentage for each using 'All Fuels'
const all = breakdown['All Fuels'];
const coal = Math.round((breakdown['Coal'] / all) * 100);
const petroleum = Math.round((breakdown['Petroleum'] / all) * 100);
const naturalGas = Math.round((breakdown['Natural Gas'] / all) * 100);
const nuclear = Math.round((breakdown['Nuclear'] / all) * 100);
const hydro = Math.round((breakdown['Hydro'] / all) * 100);
const wind = Math.round((breakdown['Wind'] / all) * 100);
const solar = Math.round((breakdown['Solar'] / all) * 100);
const other = Math.round((breakdown['Other Renewable'] / all) * 100);
const all = breakdown.all_fuels;
const coal = Math.round((breakdown.coal / all) * 100);
const petroleum = Math.round((breakdown.petroleum / all) * 100);
const naturalGas = Math.round((breakdown.natural_gas / all) * 100);
const nuclear = Math.round((breakdown.nuclear / all) * 100);
const hydro = Math.round((breakdown.hydro / all) * 100);
const wind = Math.round((breakdown.wind / all) * 100);
const solar = Math.round((breakdown.solar / all) * 100);
const other = Math.round((breakdown.other_renewable / all) * 100);

return {
Coal: {
yourState: coal,
yourState: isNaN(coal) ? 0 : coal,
color: 'red',
nationalAverage: 22
},
Petroleum: {
yourState: petroleum,
yourState: isNaN(petroleum) ? 0 : petroleum,
color: 'orange',
nationalAverage: 0.8
},
'Natural Gas': {
yourState: naturalGas,
yourState: isNaN(naturalGas) ? 0 : naturalGas,
color: 'gold',
nationalAverage: 38
},
Nuclear: {
yourState: nuclear,
yourState: isNaN(nuclear) ? 0 : nuclear,
color: 'teal',
nationalAverage: 19
},
Hydro: {
yourState: hydro,
yourState: isNaN(hydro) ? 0 : hydro,
color: 'teal',
nationalAverage: 6
},
Wind: {
yourState: wind,
yourState: isNaN(wind) ? 0 : wind,
color: 'teal',
nationalAverage: 9
},
Solar: {
yourState: solar,
yourState: isNaN(solar) ? 0 : solar,
color: 'teal',
nationalAverage: 3
},
Other: {
yourState: other,
yourState: isNaN(other) ? 0 : other,
color: 'teal',
nationalAverage: 2
}
Expand All @@ -80,6 +80,7 @@ const Zipdata = ({ zipcode }) => {
useEffect(() => {
if (zipcode) {
emission_breakdown(zipcode).then((data) => {
console.log("idk", data);
setTable(data);
});
}
Expand Down
1 change: 1 addition & 0 deletions src/helpers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const convertZipToState = (zipcode) => {
const state = states.find(function (s) {
return s.min <= zipcode && s.max >= zipcode;
});
console.log('my state', state);
return state;
};

Expand Down
7 changes: 5 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ cache: false,
devServer: {
proxy: {
'/api': 'https://api.zwell.io'
},
},
headers: {
"Access-Control-Allow-Origin": "*",
},
port: 3000,
historyApiFallback: true
},
Expand Down Expand Up @@ -41,5 +44,5 @@ cache: false,
},
]
},
plugins: [new HtmlWebpackPlugin({ template: './src/index.html' })],
plugins: [new HtmlWebpackPlugin({ template: './public/index.html' })],
}

0 comments on commit 7c902f2

Please sign in to comment.