Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
style: cleaned up the code
Browse files Browse the repository at this point in the history
  • Loading branch information
yosephAHMED committed Aug 20, 2020
1 parent f2bc985 commit d3cdfa2
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/incidents/visualize/VisualizeIncidents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,28 @@ const VisualizeIncidents = () => {
0,
])

const getIncidentMonth = (reportedOn: string) =>
// reportedOn: "2020-08-12T19:53:30.153Z"
Number(reportedOn.slice(5, 7)) - 1

const handleUpdate = (incidentMonth: number) => {
console.log('monthlyIncidents:', monthlyIncidents)
const newMonthlyIncidents = [...monthlyIncidents]
newMonthlyIncidents[incidentMonth] += 1
console.log('newMonthlyIncidents: ', newMonthlyIncidents)
setMonthlyIncidents(newMonthlyIncidents)
}

const getIncidentMonth = (reportedOn: string) =>
// reportedOn: "2020-08-12T19:53:30.153Z"
Number(reportedOn.slice(5, 7)) - 1

useEffect(() => {
if (data === undefined || isLoading) {
console.log('data is undefined')
// const spinner = <Spinner type="DotLoader" loading />
} else {
const totalIncidents: number = data.length
for (let incident = 0; incident < totalIncidents; incident += 1) {
const incidentMonth = getIncidentMonth(data[incident].reportedOn)
console.log('iteration number ', incident)
handleUpdate(incidentMonth)
}
}
}, [data])

// console.log("after updating: ", monthlyIncidents)

return (
<>
<LineGraph
Expand Down

0 comments on commit d3cdfa2

Please sign in to comment.