mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 01:35:17 +01:00
55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
import React, { useState, useEffect } from 'react';
|
|
import { useRouter } from 'next/router';
|
|
import { get } from 'lib/web';
|
|
import Link from './interface/Link';
|
|
import WebsiteChart from './charts/WebsiteChart';
|
|
import Page from './layout/Page';
|
|
import Icon from './interface/Icon';
|
|
import Button from './interface/Button';
|
|
import PageHeader from './layout/PageHeader';
|
|
import Arrow from 'assets/arrow-right.svg';
|
|
import styles from './WebsiteList.module.css';
|
|
|
|
export default function WebsiteList() {
|
|
const [data, setData] = useState();
|
|
const router = useRouter();
|
|
|
|
async function loadData() {
|
|
setData(await get(`/api/website`));
|
|
}
|
|
|
|
useEffect(() => {
|
|
loadData();
|
|
}, []);
|
|
|
|
return (
|
|
<Page>
|
|
{data?.map(({ website_id, name }) => (
|
|
<div key={website_id} className={styles.website}>
|
|
<PageHeader>
|
|
<Link
|
|
href="/website/[...id]"
|
|
as={`/website/${website_id}/${name}`}
|
|
className={styles.title}
|
|
>
|
|
{name}
|
|
</Link>
|
|
<Button
|
|
icon={<Arrow />}
|
|
onClick={() =>
|
|
router.push('/website/[...id]', `/website/${website_id}/${name}`, {
|
|
shallow: true,
|
|
})
|
|
}
|
|
size="S"
|
|
>
|
|
<div>View details</div>
|
|
</Button>
|
|
</PageHeader>
|
|
<WebsiteChart key={website_id} title={name} websiteId={website_id} />
|
|
</div>
|
|
))}
|
|
</Page>
|
|
);
|
|
}
|