import { useState } from 'react'; import { Icons, Loading } from 'react-basics'; import { useIntl } from 'react-intl'; import Link from 'next/link'; import classNames from 'classnames'; import Page from 'components/layout/Page'; import WebsiteChart from 'components/metrics/WebsiteChart'; import useApi from 'hooks/useApi'; import usePageQuery from 'hooks/usePageQuery'; import { DEFAULT_ANIMATION_DURATION } from 'lib/constants'; import WebsiteTableView from './WebsiteTableView'; import WebsiteMenuView from './WebsiteMenuView'; export default function WebsiteDetails({ websiteId }) { const { get, useQuery } = useApi(); const { data, isLoading, error } = useQuery(['websites', websiteId], () => get(`/websites/${websiteId}`), ); const [chartLoaded, setChartLoaded] = useState(false); const { query: { view }, } = usePageQuery(); function handleDataLoad() { if (!chartLoaded) { setTimeout(() => setChartLoaded(true), DEFAULT_ANIMATION_DURATION); } } return ( {!chartLoaded && } {chartLoaded && ( <> {!view && } {view && } )} ); }