import React, { useState } from 'react'; import { FormattedMessage } from 'react-intl'; import Link from 'components/common/Link'; import WebsiteChart from 'components/metrics/WebsiteChart'; import Page from 'components/layout/Page'; import EmptyPlaceholder from 'components/common/EmptyPlaceholder'; import useFetch from 'hooks/useFetch'; import DashboardSettingsButton from 'components/settings/DashboardSettingsButton'; import Button from 'components/common/Button'; import useStore from 'store/app'; import Arrow from 'assets/arrow-right.svg'; import styles from './WebsiteList.module.css'; const selector = state => state.dashboard; export default function WebsiteList({ userId }) { const { data } = useFetch('/websites', { params: { user_id: userId } }); const { showCharts, limit } = useStore(selector); const [max, setMax] = useState(limit); function handleMore() { setMax(max + limit); } if (!data) { return null; } if (data.length === 0) { return ( } > } iconRight> ); } return (
{data.map(({ website_id, name, domain }, index) => index < max ? (
) : null, )} {max < data.length && ( )}
); }