import React, { useEffect, useState } from 'react'; import classNames from 'classnames'; import WebsiteChart from './WebsiteChart'; import RankingsChart from './RankingsChart'; import WorldMap from './WorldMap'; import Page from './Page'; import { getDateRange } from 'lib/date'; import { get } from 'lib/web'; import { browserFilter, urlFilter, refFilter, deviceFilter, countryFilter } from 'lib/filters'; import styles from './WebsiteDetails.module.css'; const pageviewClasses = 'col-md-12 col-lg-6'; const sessionClasses = 'col-12 col-lg-4'; export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) { const [data, setData] = useState(); const [chartLoaded, setChartLoaded] = useState(false); const [countryData, setCountryData] = useState(); const [dateRange, setDateRange] = useState(getDateRange(defaultDateRange)); const { startDate, endDate } = dateRange; async function loadData() { setData(await get(`/api/website/${websiteId}`)); } function handleDataLoad() { if (!chartLoaded) setTimeout(() => setChartLoaded(true), 300); } function handleDateChange(values) { setTimeout(() => setDateRange(values), 300); } useEffect(() => { if (websiteId) { loadData(); } }, [websiteId]); if (!data) { return null; } return (

{data.name}

{chartLoaded && ( <>
setCountryData(data)} />
)}
); }