mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-14 17:25:02 +01:00
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
import React, { useState, useEffect } from 'react';
|
|
import { useRouter } from 'next/router';
|
|
import WebsiteHeader from 'components/charts/WebsiteHeader';
|
|
import WebsiteChart from 'components/charts/WebsiteChart';
|
|
import Page from 'components/layout/Page';
|
|
import Button from 'components/common/Button';
|
|
import EmptyPlaceholder from 'components/common/EmptyPlaceholder';
|
|
import Arrow from 'assets/arrow-right.svg';
|
|
import { get } from 'lib/web';
|
|
import styles from './WebsiteList.module.css';
|
|
|
|
export default function WebsiteList() {
|
|
const [data, setData] = useState();
|
|
const router = useRouter();
|
|
|
|
async function loadData() {
|
|
setData(await get(`/api/websites`));
|
|
}
|
|
|
|
useEffect(() => {
|
|
loadData();
|
|
}, []);
|
|
|
|
if (!data) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<Page>
|
|
{data?.map(({ website_id, name }) => (
|
|
<div key={website_id} className={styles.website}>
|
|
<WebsiteHeader websiteId={website_id} name={name} showLink />
|
|
<WebsiteChart key={website_id} title={name} websiteId={website_id} />
|
|
</div>
|
|
))}
|
|
{data.length === 0 && (
|
|
<EmptyPlaceholder msg={"You don't have any websites configured."}>
|
|
<Button icon={<Arrow />} size="medium" onClick={() => router.push('/settings')}>
|
|
<div>Go to settings</div>
|
|
</Button>
|
|
</EmptyPlaceholder>
|
|
)}
|
|
</Page>
|
|
);
|
|
}
|