import React, { useState } from 'react'; import { FormattedMessage } from 'react-intl'; import { useRouter } from 'next/router'; import classNames from 'classnames'; import WebsiteChart from 'components/metrics/WebsiteChart'; import WorldMap from 'components/common/WorldMap'; import Page from 'components/layout/Page'; import MenuLayout from 'components/layout/MenuLayout'; import Button from 'components/common/Button'; import Arrow from 'assets/arrow-right.svg'; import styles from './WebsiteDetails.module.css'; import PagesTable from './metrics/PagesTable'; import ReferrersTable from './metrics/ReferrersTable'; import BrowsersTable from './metrics/BrowsersTable'; import OSTable from './metrics/OSTable'; import DevicesTable from './metrics/DevicesTable'; import CountriesTable from './metrics/CountriesTable'; import EventsTable from './metrics/EventsTable'; import EventsChart from './metrics/EventsChart'; import useFetch from 'hooks/useFetch'; import Loading from 'components/common/Loading'; const views = { url: PagesTable, referrer: ReferrersTable, browser: BrowsersTable, os: OSTable, device: DevicesTable, country: CountriesTable, event: EventsTable, }; export default function WebsiteDetails({ websiteId }) { const router = useRouter(); const { data } = useFetch(`/api/website/${websiteId}`); const [chartLoaded, setChartLoaded] = useState(false); const [countryData, setCountryData] = useState(); const [eventsData, setEventsData] = useState(); const { query: { id, view }, } = router; const path = `/website/${id.join('/')}`; console.log({ router }); const BackButton = () => ( } size="xsmall" onClick={() => router.push(path)} >