2019-11-20 08:48:27 +03:00
|
|
|
import React, { useEffect } from 'react';
|
2019-11-19 07:30:42 +03:00
|
|
|
import Dash from './index'
|
2020-09-28 11:29:24 +03:00
|
|
|
import SourcesModal from './stats/modals/sources'
|
2019-11-19 07:30:42 +03:00
|
|
|
import ReferrersDrilldownModal from './stats/modals/referrer-drilldown'
|
|
|
|
import GoogleKeywordsModal from './stats/modals/google-keywords'
|
|
|
|
import PagesModal from './stats/modals/pages'
|
|
|
|
import CountriesModal from './stats/modals/countries'
|
|
|
|
|
2019-11-20 08:48:27 +03:00
|
|
|
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;
|
|
|
|
}
|
2019-11-19 07:30:42 +03:00
|
|
|
|
2020-08-13 13:45:18 +03:00
|
|
|
export default function Router({site, loggedIn}) {
|
2019-11-19 07:30:42 +03:00
|
|
|
return (
|
|
|
|
<BrowserRouter>
|
|
|
|
<Route path="/:domain">
|
2019-11-20 08:48:27 +03:00
|
|
|
<ScrollToTop />
|
2020-08-13 13:45:18 +03:00
|
|
|
<Dash site={site} loggedIn={loggedIn} />
|
2019-11-19 07:30:42 +03:00
|
|
|
<Switch>
|
2020-09-28 11:29:24 +03:00
|
|
|
<Route exact path={["/:domain/sources", "/:domain/utm_mediums", "/:domain/utm_sources", "/:domain/utm_campaigns"]}>
|
|
|
|
<SourcesModal site={site} />
|
2019-11-19 07:30:42 +03:00
|
|
|
</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/countries">
|
|
|
|
<CountriesModal site={site} />
|
|
|
|
</Route>
|
|
|
|
</Switch>
|
|
|
|
</Route>
|
|
|
|
</BrowserRouter>
|
|
|
|
);
|
|
|
|
}
|