mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-27 21:00:12 +01:00
aceb904398
* Fixed issue with realtime page rendering. * fix auth, add pg extension (#1596) * Fixed change password issue. API refactoring. Closes #1592. * Fixed account lookup. * Fixed issue with accessing user dashboards. Closes #1590 * fix sort on dashboard (#1600) Co-authored-by: Brian Cao <brian@umami.is>
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
import { useState } from 'react';
|
|
import { defineMessages, useIntl } from 'react-intl';
|
|
import Page from 'components/layout/Page';
|
|
import PageHeader from 'components/layout/PageHeader';
|
|
import WebsiteList from 'components/pages/WebsiteList';
|
|
import Button from 'components/common/Button';
|
|
import DashboardSettingsButton from 'components/settings/DashboardSettingsButton';
|
|
import useFetch from 'hooks/useFetch';
|
|
import useDashboard from 'store/dashboard';
|
|
import DashboardEdit from './DashboardEdit';
|
|
import styles from './WebsiteList.module.css';
|
|
|
|
const messages = defineMessages({
|
|
dashboard: { id: 'label.dashboard', defaultMessage: 'Dashboard' },
|
|
more: { id: 'label.more', defaultMessage: 'More' },
|
|
});
|
|
|
|
export default function Dashboard({ userId }) {
|
|
const dashboard = useDashboard();
|
|
const { showCharts, limit, editing } = dashboard;
|
|
const [max, setMax] = useState(limit);
|
|
const { data } = useFetch('/websites', { params: { user_id: userId } });
|
|
const { formatMessage } = useIntl();
|
|
|
|
function handleMore() {
|
|
setMax(max + limit);
|
|
}
|
|
|
|
if (!data) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<Page>
|
|
<PageHeader>
|
|
<div>{formatMessage(messages.dashboard)}</div>
|
|
{!editing && <DashboardSettingsButton />}
|
|
</PageHeader>
|
|
{editing && <DashboardEdit websites={data} />}
|
|
{!editing && <WebsiteList websites={data} showCharts={showCharts} limit={max} />}
|
|
{max < data.length && (
|
|
<Button className={styles.button} onClick={handleMore}>
|
|
{formatMessage(messages.more)}
|
|
</Button>
|
|
)}
|
|
</Page>
|
|
);
|
|
}
|