Skip to content

Commit

Permalink
updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
echen831 committed Dec 9, 2020
1 parent da6c886 commit 3811ee3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .eslintcache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"/Users/ericchen/Desktop/MB_projects/sj_project/src/index.js":"1","/Users/ericchen/Desktop/MB_projects/sj_project/src/App.js":"2","/Users/ericchen/Desktop/MB_projects/sj_project/src/components/input.jsx":"3","/Users/ericchen/Desktop/MB_projects/sj_project/src/components/states.js":"4","/Users/ericchen/Desktop/MB_projects/sj_project/src/components/buttons.jsx":"5","/Users/ericchen/Desktop/MB_projects/sj_project/src/components/today.jsx":"6","/Users/ericchen/Desktop/MB_projects/sj_project/src/components/history.jsx":"7"},{"size":199,"mtime":1607224861875,"results":"8","hashOfConfig":"9"},{"size":1761,"mtime":1607488680142,"results":"10","hashOfConfig":"9"},{"size":766,"mtime":1607227340486,"results":"11","hashOfConfig":"9"},{"size":5659,"mtime":1607320414068,"results":"12","hashOfConfig":"9"},{"size":816,"mtime":1607407453938,"results":"13","hashOfConfig":"9"},{"size":2190,"mtime":1607409356566,"results":"14","hashOfConfig":"9"},{"size":1710,"mtime":1607488785108,"results":"15","hashOfConfig":"9"},{"filePath":"16","messages":"17","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"18"},"150614y",{"filePath":"19","messages":"20","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"21","messages":"22","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"23","usedDeprecatedRules":"24"},{"filePath":"25","messages":"26","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"18"},{"filePath":"27","messages":"28","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"29","usedDeprecatedRules":"18"},{"filePath":"30","messages":"31","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"32","usedDeprecatedRules":"18"},{"filePath":"33","messages":"34","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/Users/ericchen/Desktop/MB_projects/sj_project/src/index.js",[],["35","36"],"/Users/ericchen/Desktop/MB_projects/sj_project/src/App.js",["37"],"/Users/ericchen/Desktop/MB_projects/sj_project/src/components/input.jsx",["38","39"],"import React, { useState, useRef } from 'react';\n\nexport const Input = ({ add }) => {\n const [name, setName] = useState('');\n\n const nameInput = useRef();\n const addressInput = useRef();\n\n const handleSubmit = (e) => {\n e.preventDefault();\n add({ name: nameInput.current.value, address: addressInput.current.value })\n nameInput.current.value = '';\n addressInput.current.value = '';\n }\n\n return (\n <div>\n <form action=\"\" onSubmit={handleSubmit}>\n <input type=\"text\" placeholder='Your name here...' ref={nameInput}/>\n <input type=\"text\" placeholder='Your address here...'ref={addressInput}/>\n <button>Submit</button>\n </form>\n </div>\n )\n}",["40","41"],"/Users/ericchen/Desktop/MB_projects/sj_project/src/components/states.js",[],"/Users/ericchen/Desktop/MB_projects/sj_project/src/components/buttons.jsx",["42","43"],"import React, {useState, useEffect} from 'react';\nimport { STATES } from './states'\n\nconst COLORS = ['red', 'blue', 'green', 'orange', 'purple', 'gold', 'indigo', 'brown']\n\nexport const Buttons = ({ setCurrState, fetchHistData }) => {\n\n return (\n <div>\n <ul className='button-wrapper'>\n {STATES.map((state, idx) => (\n <li key={state.abbreviation}\n style={{color: 'white', backgroundColor: COLORS[idx % COLORS.length]}}\n className='button'\n onClick={() => {setCurrState(state.abbreviation); \n fetchHistData(state.abbreviation.toLowerCase())}}>\n {state.abbreviation}</li>\n ))}\n </ul>\n </div>\n )\n}","/Users/ericchen/Desktop/MB_projects/sj_project/src/components/today.jsx",["44"],"import React, { useEffect, useState } from 'react';\nimport { STATES_HASH } from './states.js';\n\nexport const Today = ({currState}) => {\n\n const [error, setError] = useState(null);\n const [isLoaded, setIsLoaded] = useState(false);\n const [items, setItems] = useState([]);\n const [date, setDate] = useState(new Date());\n\n useEffect(() => {\n fetch(`https://api.covidtracking.com/v1/states/current.json`)\n .then(res => res.json())\n .then((result) => {\n setIsLoaded(true);\n setItems(result);\n },\n (error) => {\n setIsLoaded(true);\n setError(error)\n }\n )\n }, [])\n\n if (error) {\n return (\n <div>Error: {error.message}</div>\n )\n } else if (!isLoaded) {\n return <div>Loading...</div>\n } else {\n return (\n <div>\n <h1>Today's Data: {`${date.getMonth()+1}/${date.getDate()}/${date.getFullYear()}`}</h1>\n <h2>State: {STATES_HASH[currState]}</h2>\n {items.map(state => {\n const display = currState !== state.state ? 'hide' : 'state-wrapper'\n return (\n <div className={display} key={state.state}>\n <li>Total Tests</li>\n <li>Positive</li>\n <li>Negative</li>\n <li>{state.totalTestResults}</li>\n <li>{state.positive}</li>\n <li>{state.negative}</li>\n </div>\n\n )\n })}\n </div>\n )\n }\n // return (\n // <div className='map-container'>\n // {/* Map goes here...\n // <ul>\n // {names.map((name, idx) => {\n // return(\n // <div key={idx}>\n // <li>{name.name}</li>\n // <li>{name.address}</li>\n // </div>\n // )\n // })}\n // </ul> */}\n // </div>\n // )\n}","/Users/ericchen/Desktop/MB_projects/sj_project/src/components/history.jsx",["45","46","47"],{"ruleId":"48","replacedBy":"49"},{"ruleId":"50","replacedBy":"51"},{"ruleId":"52","severity":1,"message":"53","line":31,"column":48,"nodeType":"54","endLine":31,"endColumn":50,"suggestions":"55"},{"ruleId":"56","severity":1,"message":"57","line":4,"column":12,"nodeType":"58","messageId":"59","endLine":4,"endColumn":16},{"ruleId":"56","severity":1,"message":"60","line":4,"column":18,"nodeType":"58","messageId":"59","endLine":4,"endColumn":25},{"ruleId":"48","replacedBy":"61"},{"ruleId":"50","replacedBy":"62"},{"ruleId":"56","severity":1,"message":"63","line":1,"column":16,"nodeType":"58","messageId":"59","endLine":1,"endColumn":24},{"ruleId":"56","severity":1,"message":"64","line":1,"column":26,"nodeType":"58","messageId":"59","endLine":1,"endColumn":35},{"ruleId":"56","severity":1,"message":"65","line":9,"column":18,"nodeType":"58","messageId":"59","endLine":9,"endColumn":25},{"ruleId":"56","severity":1,"message":"66","line":3,"column":22,"nodeType":"58","messageId":"59","endLine":3,"endColumn":30},{"ruleId":"56","severity":1,"message":"67","line":3,"column":32,"nodeType":"58","messageId":"59","endLine":3,"endColumn":35},{"ruleId":"56","severity":1,"message":"68","line":3,"column":37,"nodeType":"58","messageId":"59","endLine":3,"endColumn":41},"no-native-reassign",["69"],"no-negated-in-lhs",["70"],"react-hooks/exhaustive-deps","React Hook useEffect has missing dependencies: 'currState' and 'fetchHistData'. Either include them or remove the dependency array.","ArrayExpression",["71"],"no-unused-vars","'name' is assigned a value but never used.","Identifier","unusedVar","'setName' is assigned a value but never used.",["69"],["70"],"'useState' is defined but never used.","'useEffect' is defined but never used.","'setDate' is assigned a value but never used.","'BarChart' is defined but never used.","'Bar' is defined but never used.","'Cell' is defined but never used.","no-global-assign","no-unsafe-negation",{"desc":"72","fix":"73"},"Update the dependencies array to be: [currState, fetchHistData]",{"range":"74","text":"75"},[693,695],"[currState, fetchHistData]"]
[{"/Users/ericchen/Desktop/MB_projects/sj_project/src/index.js":"1","/Users/ericchen/Desktop/MB_projects/sj_project/src/App.js":"2","/Users/ericchen/Desktop/MB_projects/sj_project/src/components/input.jsx":"3","/Users/ericchen/Desktop/MB_projects/sj_project/src/components/states.js":"4","/Users/ericchen/Desktop/MB_projects/sj_project/src/components/buttons.jsx":"5","/Users/ericchen/Desktop/MB_projects/sj_project/src/components/today.jsx":"6","/Users/ericchen/Desktop/MB_projects/sj_project/src/components/history.jsx":"7"},{"size":199,"mtime":1607224861875,"results":"8","hashOfConfig":"9"},{"size":1761,"mtime":1607488680142,"results":"10","hashOfConfig":"9"},{"size":766,"mtime":1607227340486,"results":"11","hashOfConfig":"9"},{"size":5659,"mtime":1607320414068,"results":"12","hashOfConfig":"9"},{"size":793,"mtime":1607494470171,"results":"13","hashOfConfig":"9"},{"size":2190,"mtime":1607409356566,"results":"14","hashOfConfig":"9"},{"size":1710,"mtime":1607488785108,"results":"15","hashOfConfig":"9"},{"filePath":"16","messages":"17","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"18"},"150614y",{"filePath":"19","messages":"20","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"21","messages":"22","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"23","usedDeprecatedRules":"24"},{"filePath":"25","messages":"26","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"18"},{"filePath":"27","messages":"28","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"29","messages":"30","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"31","usedDeprecatedRules":"18"},{"filePath":"32","messages":"33","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/Users/ericchen/Desktop/MB_projects/sj_project/src/index.js",[],["34","35"],"/Users/ericchen/Desktop/MB_projects/sj_project/src/App.js",["36"],"/Users/ericchen/Desktop/MB_projects/sj_project/src/components/input.jsx",["37","38"],"import React, { useState, useRef } from 'react';\n\nexport const Input = ({ add }) => {\n const [name, setName] = useState('');\n\n const nameInput = useRef();\n const addressInput = useRef();\n\n const handleSubmit = (e) => {\n e.preventDefault();\n add({ name: nameInput.current.value, address: addressInput.current.value })\n nameInput.current.value = '';\n addressInput.current.value = '';\n }\n\n return (\n <div>\n <form action=\"\" onSubmit={handleSubmit}>\n <input type=\"text\" placeholder='Your name here...' ref={nameInput}/>\n <input type=\"text\" placeholder='Your address here...'ref={addressInput}/>\n <button>Submit</button>\n </form>\n </div>\n )\n}",["39","40"],"/Users/ericchen/Desktop/MB_projects/sj_project/src/components/states.js",[],"/Users/ericchen/Desktop/MB_projects/sj_project/src/components/buttons.jsx",[],"/Users/ericchen/Desktop/MB_projects/sj_project/src/components/today.jsx",["41"],"import React, { useEffect, useState } from 'react';\nimport { STATES_HASH } from './states.js';\n\nexport const Today = ({currState}) => {\n\n const [error, setError] = useState(null);\n const [isLoaded, setIsLoaded] = useState(false);\n const [items, setItems] = useState([]);\n const [date, setDate] = useState(new Date());\n\n useEffect(() => {\n fetch(`https://api.covidtracking.com/v1/states/current.json`)\n .then(res => res.json())\n .then((result) => {\n setIsLoaded(true);\n setItems(result);\n },\n (error) => {\n setIsLoaded(true);\n setError(error)\n }\n )\n }, [])\n\n if (error) {\n return (\n <div>Error: {error.message}</div>\n )\n } else if (!isLoaded) {\n return <div>Loading...</div>\n } else {\n return (\n <div>\n <h1>Today's Data: {`${date.getMonth()+1}/${date.getDate()}/${date.getFullYear()}`}</h1>\n <h2>State: {STATES_HASH[currState]}</h2>\n {items.map(state => {\n const display = currState !== state.state ? 'hide' : 'state-wrapper'\n return (\n <div className={display} key={state.state}>\n <li>Total Tests</li>\n <li>Positive</li>\n <li>Negative</li>\n <li>{state.totalTestResults}</li>\n <li>{state.positive}</li>\n <li>{state.negative}</li>\n </div>\n\n )\n })}\n </div>\n )\n }\n // return (\n // <div className='map-container'>\n // {/* Map goes here...\n // <ul>\n // {names.map((name, idx) => {\n // return(\n // <div key={idx}>\n // <li>{name.name}</li>\n // <li>{name.address}</li>\n // </div>\n // )\n // })}\n // </ul> */}\n // </div>\n // )\n}","/Users/ericchen/Desktop/MB_projects/sj_project/src/components/history.jsx",["42","43","44"],{"ruleId":"45","replacedBy":"46"},{"ruleId":"47","replacedBy":"48"},{"ruleId":"49","severity":1,"message":"50","line":31,"column":48,"nodeType":"51","endLine":31,"endColumn":50,"suggestions":"52"},{"ruleId":"53","severity":1,"message":"54","line":4,"column":12,"nodeType":"55","messageId":"56","endLine":4,"endColumn":16},{"ruleId":"53","severity":1,"message":"57","line":4,"column":18,"nodeType":"55","messageId":"56","endLine":4,"endColumn":25},{"ruleId":"45","replacedBy":"58"},{"ruleId":"47","replacedBy":"59"},{"ruleId":"53","severity":1,"message":"60","line":9,"column":18,"nodeType":"55","messageId":"56","endLine":9,"endColumn":25},{"ruleId":"53","severity":1,"message":"61","line":3,"column":22,"nodeType":"55","messageId":"56","endLine":3,"endColumn":30},{"ruleId":"53","severity":1,"message":"62","line":3,"column":32,"nodeType":"55","messageId":"56","endLine":3,"endColumn":35},{"ruleId":"53","severity":1,"message":"63","line":3,"column":37,"nodeType":"55","messageId":"56","endLine":3,"endColumn":41},"no-native-reassign",["64"],"no-negated-in-lhs",["65"],"react-hooks/exhaustive-deps","React Hook useEffect has missing dependencies: 'currState' and 'fetchHistData'. Either include them or remove the dependency array.","ArrayExpression",["66"],"no-unused-vars","'name' is assigned a value but never used.","Identifier","unusedVar","'setName' is assigned a value but never used.",["64"],["65"],"'setDate' is assigned a value but never used.","'BarChart' is defined but never used.","'Bar' is defined but never used.","'Cell' is defined but never used.","no-global-assign","no-unsafe-negation",{"desc":"67","fix":"68"},"Update the dependencies array to be: [currState, fetchHistData]",{"range":"69","text":"70"},[693,695],"[currState, fetchHistData]"]
2 changes: 1 addition & 1 deletion src/components/buttons.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState, useEffect} from 'react';
import React from 'react';
import { STATES } from './states'

const COLORS = ['red', 'blue', 'green', 'orange', 'purple', 'gold', 'indigo', 'brown']
Expand Down

0 comments on commit 3811ee3

Please sign in to comment.