diff --git a/package.json b/package.json index 70d0b97..c47a4de 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/Location/ZipDataComponent/zipdata.jsx b/src/components/Location/ZipDataComponent/zipdata.jsx index 1ef11cf..2ce9907 100644 --- a/src/components/Location/ZipDataComponent/zipdata.jsx +++ b/src/components/Location/ZipDataComponent/zipdata.jsx @@ -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 } @@ -80,6 +80,7 @@ const Zipdata = ({ zipcode }) => { useEffect(() => { if (zipcode) { emission_breakdown(zipcode).then((data) => { + console.log("idk", data); setTable(data); }); } diff --git a/src/helpers/api.js b/src/helpers/api.js index c27bbb2..b70b23e 100644 --- a/src/helpers/api.js +++ b/src/helpers/api.js @@ -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; }; diff --git a/webpack.config.js b/webpack.config.js index d65c69c..cd20d83 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -12,7 +12,10 @@ cache: false, devServer: { proxy: { '/api': 'https://api.zwell.io' - }, + }, + headers: { + "Access-Control-Allow-Origin": "*", +}, port: 3000, historyApiFallback: true }, @@ -41,5 +44,5 @@ cache: false, }, ] }, - plugins: [new HtmlWebpackPlugin({ template: './src/index.html' })], + plugins: [new HtmlWebpackPlugin({ template: './public/index.html' })], } \ No newline at end of file