Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

fix(stats): handle redirections with slash prefix #523

Merged
merged 1 commit into from Oct 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions pages/stats/index.jsx
Expand Up @@ -92,6 +92,7 @@ const Charts = ({ group }) => {
const Stats = () => {
const router = useRouter();
const { region = "national" } = router.query;
const regionId = region.replace(/^\//,"");
const { data } = useQuery("dashboard", () => fetch("/dashboard.json").then((r) => r.json()));
return (
<Box bg="white" p={4}>
Expand All @@ -100,9 +101,9 @@ const Stats = () => {
</Head>
<Wrapper>
<Flex flexDirection="row">
<Box width={200}>{data && <Menu groups={data.groups} selected={region} />}</Box>
<Box width={200}>{data && <Menu groups={data.groups} selected={regionId} />}</Box>
<Box width="100%">
{(data && <Charts group={data.groups.find((g) => g.id === region)} />) || (
{(data && <Charts group={data.groups.find((g) => g.id === regionId)} />) || (
<div>chargement...</div>
)}
</Box>
Expand Down