-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #306 from caktus/develop
Production release v1.20.0
- Loading branch information
Showing
62 changed files
with
24,194 additions
and
1,153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import ArrestsStyled from './Arrests.styles'; | ||
|
||
// Hooks | ||
import useMetaTags from '../../../Hooks/useMetaTags'; | ||
import useTableModal from '../../../Hooks/useTableModal'; | ||
|
||
// Children | ||
import PercentageOfStops from './Charts/PercentageOfStops'; | ||
import PercentageOfSearches from './Charts/PercentageOfSearches'; | ||
import CountOfStopsAndArrests from './Charts/CountOfStopsAndArrests'; | ||
import PercentageOfStopsForStopPurposeGroup from './Charts/PercentageOfStopsForPurposeGroup'; | ||
import PercentageOfStopsForStopPurpose from './Charts/PercentageOfStopsPerStopPurpose'; | ||
import PercentageOfSearchesForStopPurposeGroup from './Charts/PercentageOfSearchesForPurposeGroup'; | ||
import PercentageOfSearchesPerStopPurpose from './Charts/PercentageOfSearchesPerStopPurpose'; | ||
import PercentageOfStopsPerContrabandType from './Charts/PercentageOfStopsPerContrabandType'; | ||
import Switch from 'react-switch'; | ||
import { SwitchContainer } from '../TrafficStops/TrafficStops.styled'; | ||
|
||
function Arrests(props) { | ||
const { year } = props; | ||
const [togglePercentageOfStops, setTogglePercentageOfStops] = useState(true); | ||
const [togglePercentageOfSearches, setTogglePercentageOfSearches] = useState(true); | ||
|
||
const renderMetaTags = useMetaTags(); | ||
const [renderTableModal] = useTableModal(); | ||
|
||
useEffect(() => { | ||
if (window.location.hash) { | ||
document.querySelector(`${window.location.hash}`).scrollIntoView(); | ||
} | ||
}, []); | ||
|
||
const stopGraphToggle = () => ( | ||
<SwitchContainer> | ||
<span> | ||
Switch to view {togglePercentageOfStops ? 'all stop purposes' : 'grouped stop purposes '} | ||
</span> | ||
<Switch | ||
onChange={() => setTogglePercentageOfStops(!togglePercentageOfStops)} | ||
checked={togglePercentageOfStops} | ||
className="react-switch" | ||
/> | ||
</SwitchContainer> | ||
); | ||
|
||
const searchGraphToggle = () => ( | ||
<SwitchContainer> | ||
<span> | ||
Switch to view {togglePercentageOfSearches ? 'all stop purposes' : 'grouped stop purposes '} | ||
</span> | ||
<Switch | ||
onChange={() => setTogglePercentageOfSearches(!togglePercentageOfSearches)} | ||
checked={togglePercentageOfSearches} | ||
className="react-switch" | ||
/> | ||
</SwitchContainer> | ||
); | ||
|
||
return ( | ||
<ArrestsStyled> | ||
{renderMetaTags()} | ||
{renderTableModal()} | ||
<PercentageOfStops {...props} year={year} /> | ||
<PercentageOfSearches {...props} year={year} /> | ||
<CountOfStopsAndArrests {...props} year={year} /> | ||
|
||
{togglePercentageOfStops ? ( | ||
<PercentageOfStopsForStopPurposeGroup {...props} year={year}> | ||
{stopGraphToggle()} | ||
</PercentageOfStopsForStopPurposeGroup> | ||
) : ( | ||
<PercentageOfStopsForStopPurpose {...props} year={year}> | ||
{stopGraphToggle()} | ||
</PercentageOfStopsForStopPurpose> | ||
)} | ||
|
||
{togglePercentageOfSearches ? ( | ||
<PercentageOfSearchesForStopPurposeGroup {...props} year={year}> | ||
{searchGraphToggle()} | ||
</PercentageOfSearchesForStopPurposeGroup> | ||
) : ( | ||
<PercentageOfSearchesPerStopPurpose {...props} year={year}> | ||
{searchGraphToggle()} | ||
</PercentageOfSearchesPerStopPurpose> | ||
)} | ||
|
||
<PercentageOfStopsPerContrabandType {...props} year={year} /> | ||
</ArrestsStyled> | ||
); | ||
} | ||
|
||
export default Arrests; |
Oops, something went wrong.