mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 01:35:17 +01:00
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
import React, { useState, useEffect } from 'react';
|
|
import Link from './Link';
|
|
import WebsiteChart from './WebsiteChart';
|
|
import Page from './Page';
|
|
import Icon from './Icon';
|
|
import { get } from 'lib/web';
|
|
import Arrow from 'assets/arrow-right.svg';
|
|
import styles from './WebsiteList.module.css';
|
|
|
|
export default function WebsiteList() {
|
|
const [data, setData] = useState();
|
|
|
|
async function loadData() {
|
|
setData(await get(`/api/website`));
|
|
}
|
|
|
|
useEffect(() => {
|
|
loadData();
|
|
}, []);
|
|
|
|
return (
|
|
<Page>
|
|
{data &&
|
|
data.websites.map(({ website_id, label }) => (
|
|
<div key={website_id} className={styles.website}>
|
|
<div className={styles.header}>
|
|
<h2>
|
|
<Link
|
|
href="/website/[...id]"
|
|
as={`/website/${website_id}/${label}`}
|
|
className={styles.title}
|
|
>
|
|
{label}
|
|
</Link>
|
|
</h2>
|
|
<Link
|
|
href="/website/[...id]"
|
|
as={`/website/${website_id}/${label}`}
|
|
className={styles.details}
|
|
>
|
|
<Icon icon={<Arrow />} /> View details
|
|
</Link>
|
|
</div>
|
|
<WebsiteChart key={website_id} title={label} websiteId={website_id} />
|
|
</div>
|
|
))}
|
|
</Page>
|
|
);
|
|
}
|