diff --git a/frontend/src/Components/Charts/Contraband/Contraband.js b/frontend/src/Components/Charts/Contraband/Contraband.js
index 7ac231df..5dc391eb 100644
--- a/frontend/src/Components/Charts/Contraband/Contraband.js
+++ b/frontend/src/Components/Charts/Contraband/Contraband.js
@@ -14,9 +14,6 @@ import {
import useMetaTags from '../../../Hooks/useMetaTags';
import useTableModal from '../../../Hooks/useTableModal';
-// State
-import useDataset, { AGENCY_DETAILS, CONTRABAND_HIT_RATE } from '../../../Hooks/useDataset';
-
// Children
import { P, WEIGHTS } from '../../../styles/StyledComponents/Typography';
import ChartHeader from '../ChartSections/ChartHeader';
@@ -34,10 +31,9 @@ import { ChartContainer } from '../ChartSections/ChartsCommon.styled';
const STOP_PURPOSE_TYPES = ['Safety Violation', 'Regulatory and Equipment', 'Other'];
function Contraband(props) {
- const { agencyId, yearRange, year } = props;
+ const { agencyId, agencyName, yearRange, year } = props;
const officerId = useOfficerId();
- const [chartState] = useDataset(agencyId, CONTRABAND_HIT_RATE);
useEffect(() => {
if (window.location.hash) {
@@ -508,7 +504,7 @@ function Contraband(props) {
const getBarChartModalSubHeading = (title) => `${title} ${subjectObserving()}.`;
const getBarChartModalHeading = (title) => {
- let subject = chartState.data[AGENCY_DETAILS].name;
+ let subject = agencyName;
if (officerId) {
subject = `Officer ${officerId}`;
}
@@ -566,7 +562,7 @@ function Contraband(props) {
@@ -609,7 +605,7 @@ function Contraband(props) {
@@ -657,7 +653,7 @@ function Contraband(props) {
@@ -702,7 +698,7 @@ function Contraband(props) {
{
- let subject = chartState.data[AGENCY_DETAILS].name;
+ let subject = agencyName;
if (officerId) {
subject = `Officer ${officerId}`;
}
@@ -161,10 +160,7 @@ function Overview(props) {
}
}, [chartState.data[USE_OF_FORCE], year]);
- const getPageTitleForShare = () => {
- const agencyName = chartState.data[AGENCY_DETAILS].name;
- return `Traffic Stop statistics for ${agencyName}`;
- };
+ const getPageTitleForShare = () => `Traffic Stop statistics for ${agencyName}`;
const useOfForcePieChartCopy = () => {
if (officerId) {
@@ -204,7 +200,7 @@ function Overview(props) {
tableSubheader: `This data reflects the race/ethnic composition based on the most recent census data.
While it can be used for general comparative purposes, the actual driving population may
vary significantly from these figures.`,
- agencyName: chartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: pieChartTitle('Census Demographics'),
}}
/>
@@ -229,7 +225,7 @@ function Overview(props) {
tableSubheader: getChartModalSubHeading(
'Shows the race/ethnic composition of drivers stopped'
),
- agencyName: chartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: pieChartTitle('Traffic Stops'),
}}
/>
@@ -256,7 +252,7 @@ function Overview(props) {
tableSubheader: getChartModalSubHeading(
'Shows the race/ethnic composition of drivers searched'
),
- agencyName: chartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: pieChartTitle('Searches'),
}}
/>
@@ -277,7 +273,7 @@ function Overview(props) {
modalConfig={{
tableHeader: 'Use of Force',
tableSubheader: getOverviewSubheader(),
- agencyName: chartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: pieChartTitle('Use of Force'),
}}
/>
diff --git a/frontend/src/Components/Charts/SearchRate/SearchRate.js b/frontend/src/Components/Charts/SearchRate/SearchRate.js
index 7b7d27db..0af1d845 100644
--- a/frontend/src/Components/Charts/SearchRate/SearchRate.js
+++ b/frontend/src/Components/Charts/SearchRate/SearchRate.js
@@ -3,7 +3,7 @@ import SearchRateStyled from './SearchRate.styled';
import * as S from '../ChartSections/ChartsCommon.styled';
// Data
-import useDataset, { AGENCY_DETAILS, LIKELIHOOD_OF_SEARCH } from '../../../Hooks/useDataset';
+import { LIKELIHOOD_OF_SEARCH } from '../../../Hooks/useDataset';
// Hooks
import useOfficerId from '../../../Hooks/useOfficerId';
@@ -21,11 +21,9 @@ import HorizontalBarChart from '../../NewCharts/HorizontalBarChart';
import { ChartContainer } from '../ChartSections/ChartsCommon.styled';
function SearchRate(props) {
- const { agencyId, yearRange, year } = props;
+ const { agencyId, agencyName, yearRange, year } = props;
const officerId = useOfficerId();
- const [chartState] = useDataset(agencyId, LIKELIHOOD_OF_SEARCH);
-
const initData = { labels: [], datasets: [], loading: true };
const [searchRateData, setSearchRateData] = useState(initData);
@@ -76,7 +74,7 @@ function SearchRate(props) {
purposes ${subjectObserving()}.`;
const getBarChartModalHeading = (title) => {
- let subject = chartState.data[AGENCY_DETAILS].name;
+ let subject = agencyName;
if (officerId) {
subject = `Officer ${officerId}`;
}
@@ -105,7 +103,6 @@ function SearchRate(props) {
incidents. Use “View Data” to see the numbers underlying the calculations.
-
diff --git a/frontend/src/Components/Charts/Searches/Searches.js b/frontend/src/Components/Charts/Searches/Searches.js
index de8cf481..45e28e30 100644
--- a/frontend/src/Components/Charts/Searches/Searches.js
+++ b/frontend/src/Components/Charts/Searches/Searches.js
@@ -6,12 +6,7 @@ import * as S from '../ChartSections/ChartsCommon.styled';
import { RACE_TABLE_COLUMNS, SEARCH_TYPE_DEFAULT, SEARCH_TYPES } from '../chartUtils';
// State
-import useDataset, {
- AGENCY_DETAILS,
- SEARCHES,
- SEARCHES_BY_TYPE,
- STOPS,
-} from '../../../Hooks/useDataset';
+import useDataset, { SEARCHES, SEARCHES_BY_TYPE, STOPS } from '../../../Hooks/useDataset';
// Hooks
import useMetaTags from '../../../Hooks/useMetaTags';
@@ -30,13 +25,12 @@ import axios from '../../../Services/Axios';
import { ChartContainer } from '../ChartSections/ChartsCommon.styled';
function Searches(props) {
- const { agencyId } = props;
+ const { agencyId, agencyName } = props;
const officerId = useOfficerId();
useDataset(agencyId, STOPS);
useDataset(agencyId, SEARCHES);
- const [chartState] = useDataset(agencyId, SEARCHES_BY_TYPE);
useEffect(() => {
if (window.location.hash) {
@@ -140,7 +134,7 @@ function Searches(props) {
};
const getLineChartModalHeading = (title, showStopPurpose = false) => {
- let subject = chartState.data[AGENCY_DETAILS].name;
+ let subject = agencyName;
if (officerId) {
subject = `Officer ${officerId}`;
}
@@ -192,7 +186,7 @@ function Searches(props) {
tableSubheader: getLineChartModalSubHeading(
'Shows the percent of stops that led to searches, broken down by race/ethnicity'
),
- agencyName: chartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: getLineChartModalHeading('Searches By Percentage', false),
}}
/>
@@ -237,7 +231,7 @@ function Searches(props) {
tableSubheader: getLineChartModalSubHeading(
`Shows the number of searches performed ${subjectObserving()}, broken down by search type and race / ethnicity`
),
- agencyName: chartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: getLineChartModalHeading('Searches By Count', true),
}}
/>
diff --git a/frontend/src/Components/Charts/TrafficStops/TrafficStops.js b/frontend/src/Components/Charts/TrafficStops/TrafficStops.js
index 7f347abd..d25670da 100644
--- a/frontend/src/Components/Charts/TrafficStops/TrafficStops.js
+++ b/frontend/src/Components/Charts/TrafficStops/TrafficStops.js
@@ -28,7 +28,7 @@ import {
} from '../chartUtils';
// State
-import useDataset, { STOPS_BY_REASON, STOPS, AGENCY_DETAILS } from '../../../Hooks/useDataset';
+import useDataset, { STOPS_BY_REASON, STOPS } from '../../../Hooks/useDataset';
// Elements
import { P, WEIGHTS } from '../../../styles/StyledComponents/Typography';
@@ -55,7 +55,7 @@ import VerticalBarChart from '../../NewCharts/VerticalBarChart';
import { ChartContainer } from '../ChartSections/ChartsCommon.styled';
function TrafficStops(props) {
- const { agencyId, showCompare, yearRange, year, yearIdx } = props;
+ const { agencyId, agencyName, showCompare, yearRange, year, yearIdx } = props;
const theme = useTheme();
const officerId = useOfficerId();
@@ -603,7 +603,7 @@ function TrafficStops(props) {
};
const pieChartTitle = () => {
- let subject = stopsChartState.data[AGENCY_DETAILS].name;
+ let subject = agencyName;
if (officerId) {
subject = `Officer ${officerId}`;
}
@@ -618,7 +618,7 @@ function TrafficStops(props) {
};
const stopPurposeGroupPieChartTitle = () => {
- let subject = stopsChartState.data[AGENCY_DETAILS].name;
+ let subject = agencyName;
if (officerId) {
subject = `Officer ${officerId}`;
}
@@ -628,7 +628,7 @@ function TrafficStops(props) {
};
const getPieChartModalHeading = (stopPurpose) => {
- let subject = stopsChartState.data[AGENCY_DETAILS].name;
+ let subject = agencyName;
if (officerId) {
subject = `Officer ${officerId}`;
}
@@ -649,7 +649,7 @@ function TrafficStops(props) {
};
const getLineChartModalHeading = (title, showStopPurpose = false) => {
- let subject = stopsChartState.data[AGENCY_DETAILS].name;
+ let subject = agencyName;
if (officerId) {
subject = `Officer ${officerId}`;
}
@@ -666,7 +666,7 @@ function TrafficStops(props) {
const formatTooltipValue = (ctx) => `${ctx.dataset.label}: ${(ctx.raw * 100).toFixed(2)}%`;
const stopsByPercentageModalTitle = () => {
- let subject = stopsChartState.data[AGENCY_DETAILS].name;
+ let subject = agencyName;
if (officerId) {
subject = `Officer ${officerId}`;
}
@@ -710,12 +710,11 @@ function TrafficStops(props) {
modalConfig={{
tableHeader: 'Traffic Stops By Percentage',
tableSubheader: `Shows the race/ethnic composition of drivers stopped ${subjectObserving()} over time.`,
- agencyName: stopsChartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: stopsByPercentageModalTitle(),
}}
/>
-
@@ -756,7 +755,7 @@ function TrafficStops(props) {
tableSubheader: getLineChartModalSubHeading(
'Shows the number of traffics stops broken down by purpose and race / ethnicity'
),
- agencyName: stopsChartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: getLineChartModalHeading('Traffic Stops By Count', true),
}}
/>
@@ -788,7 +787,7 @@ function TrafficStops(props) {
@@ -825,7 +824,7 @@ function TrafficStops(props) {
'Shows the stop purpose and race/ethnic composition of drivers stopped',
year
),
- agencyName: stopsChartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: stopPurposeGroupPieChartTitle(),
}}
/>
@@ -845,7 +844,7 @@ function TrafficStops(props) {
@@ -915,7 +914,7 @@ function TrafficStops(props) {
tableSubheader: getLineChartModalSubHeading(
'Shows the number of traffics stops broken down by purpose and race / ethnicity'
),
- agencyName: stopsChartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: getLineChartModalHeading(
'Traffic Stops Grouped By Regulatory/Equipment'
),
@@ -938,7 +937,7 @@ function TrafficStops(props) {
tableSubheader: getLineChartModalSubHeading(
'Shows the number of traffics stops broken down by purpose and race / ethnicity'
),
- agencyName: stopsChartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: getLineChartModalHeading('Traffic Stops Grouped By Other'),
}}
/>
@@ -957,7 +956,7 @@ function TrafficStops(props) {
tableSubheader: getPieChartModalSubHeading(
'Shows the number of traffics stops broken down by purpose and race / ethnicity'
),
- agencyName: stopsChartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: getPieChartModalHeading('Safety Violation'),
}}
/>
@@ -975,7 +974,7 @@ function TrafficStops(props) {
tableSubheader: getPieChartModalSubHeading(
'Shows the number of traffics stops broken down by purpose and race / ethnicity'
),
- agencyName: stopsChartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: getPieChartModalHeading('Regulatory/Equipment'),
}}
/>
@@ -993,7 +992,7 @@ function TrafficStops(props) {
tableSubheader: getPieChartModalSubHeading(
'Shows the number of traffics stops broken down by purpose and race / ethnicity'
),
- agencyName: stopsChartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: getPieChartModalHeading('Other'),
}}
/>
diff --git a/frontend/src/Components/Charts/UseOfForce/UseOfForce.js b/frontend/src/Components/Charts/UseOfForce/UseOfForce.js
index dcd50115..df9f8a94 100644
--- a/frontend/src/Components/Charts/UseOfForce/UseOfForce.js
+++ b/frontend/src/Components/Charts/UseOfForce/UseOfForce.js
@@ -13,7 +13,7 @@ import {
} from '../chartUtils';
// State
-import useDataset, { AGENCY_DETAILS, USE_OF_FORCE } from '../../../Hooks/useDataset';
+import useDataset, { USE_OF_FORCE } from '../../../Hooks/useDataset';
// Hooks
import useMetaTags from '../../../Hooks/useMetaTags';
@@ -30,7 +30,7 @@ import axios from '../../../Services/Axios';
import { ChartContainer } from '../ChartSections/ChartsCommon.styled';
function UseOfForce(props) {
- const { agencyId, year } = props;
+ const { agencyId, agencyName, year } = props;
const officerId = useOfficerId();
const [chartState] = useDataset(agencyId, USE_OF_FORCE);
@@ -115,7 +115,7 @@ function UseOfForce(props) {
};
const chartModalTitle = (displayYear = true) => {
- let subject = chartState.data[AGENCY_DETAILS].name;
+ let subject = agencyName;
if (officerId) {
subject = `Officer ${officerId}`;
}
@@ -154,7 +154,7 @@ function UseOfForce(props) {
modalConfig={{
tableHeader: 'Use of Force',
tableSubheader: getChartModalSubHeading(false),
- agencyName: chartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: chartModalTitle(false),
}}
/>
@@ -167,7 +167,7 @@ function UseOfForce(props) {
modalConfig={{
tableHeader: 'Use of Force',
tableSubheader: getChartModalSubHeading(),
- agencyName: chartState.data[AGENCY_DETAILS].name,
+ agencyName,
chartTitle: chartModalTitle(),
}}
/>