import { useState } from 'react'; import { Button, Icon, Icons, Text, Flexbox } from 'react-basics'; import Link from 'next/link'; import Page from 'components/layout/Page'; import PageHeader from 'components/layout/PageHeader'; import WebsiteChartList from 'components/pages/websites/WebsiteChartList'; import DashboardSettingsButton from 'components/pages/dashboard/DashboardSettingsButton'; import DashboardEdit from 'components/pages/dashboard/DashboardEdit'; import EmptyPlaceholder from 'components/common/EmptyPlaceholder'; import useApi from 'hooks/useApi'; import useDashboard from 'store/dashboard'; import useMessages from 'hooks/useMessages'; import useLocale from 'hooks/useLocale'; export function Dashboard({ userId }) { const { formatMessage, labels, messages } = useMessages(); const dashboard = useDashboard(); const { showCharts, limit, editing } = dashboard; const [max, setMax] = useState(limit); const { get, useQuery } = useApi(); const { data, isLoading, error } = useQuery(['websites'], () => get('/websites', { userId })); const hasData = data && data.length !== 0; const { dir } = useLocale(); function handleMore() { setMax(max + limit); } return ( {!editing && hasData && } {!hasData && ( )} {hasData && ( <> {editing && } {!editing && } {max < data.length && ( )} )} ); } export default Dashboard;