analytics/assets/js/dashboard/router.js
Uku Taht 0de89bad82
Add filter groups (#1167)
* Add filter groups

* New flow for filters

* Visual consistency

* Mobile improvements to dropdown

* Do not let filters wrap on a new line

* Fix country filter

* Add mix format to pre-commit configuration

* Make eslint happy

* Fix formatting

* Use transition from headlessUI
2021-07-21 16:50:26 +03:00

62 lines
2.0 KiB
JavaScript

import React, { useEffect } from 'react';
import Dash from './index'
import SourcesModal from './stats/modals/sources'
import ReferrersDrilldownModal from './stats/modals/referrer-drilldown'
import GoogleKeywordsModal from './stats/modals/google-keywords'
import PagesModal from './stats/modals/pages'
import EntryPagesModal from './stats/modals/entry-pages'
import ExitPagesModal from './stats/modals/exit-pages'
import CountriesModal from './stats/modals/countries'
import FilterModal from './stats/modals/filter'
import {BrowserRouter, Switch, Route, useLocation} from "react-router-dom";
function ScrollToTop() {
const location = useLocation();
useEffect(() => {
if (location.state && location.state.scrollTop) {
window.scrollTo(0, 0);
}
}, [location]);
return null;
}
export default function Router({site, loggedIn, currentUserRole}) {
return (
<BrowserRouter>
<Route path="/:domain">
<ScrollToTop />
<Dash site={site} loggedIn={loggedIn} currentUserRole={currentUserRole} />
<Switch>
<Route exact path={["/:domain/sources", "/:domain/utm_mediums", "/:domain/utm_sources", "/:domain/utm_campaigns"]}>
<SourcesModal site={site} />
</Route>
<Route exact path="/:domain/referrers/Google">
<GoogleKeywordsModal site={site} />
</Route>
<Route exact path="/:domain/referrers/:referrer">
<ReferrersDrilldownModal site={site} />
</Route>
<Route path="/:domain/pages">
<PagesModal site={site} />
</Route>
<Route path="/:domain/entry-pages">
<EntryPagesModal site={site} />
</Route>
<Route path="/:domain/exit-pages">
<ExitPagesModal site={site} />
</Route>
<Route path="/:domain/countries">
<CountriesModal site={site} />
</Route>
<Route path={["/:domain/filter/:field"]}>
<FilterModal site={site} />
</Route>
</Switch>
</Route>
</BrowserRouter>
);
}