mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Website components. Update chart component.
This commit is contained in:
parent
d81ee3932d
commit
bdcdcd9d13
9 changed files with 165 additions and 43 deletions
41
components/WebsiteList.js
Normal file
41
components/WebsiteList.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import { get } from 'lib/web';
|
||||
import WebsiteStats from './WebsiteStats';
|
||||
import DateFilter from './DateFilter';
|
||||
import { getDateRange } from '../lib/date';
|
||||
|
||||
export default function WebsiteList() {
|
||||
const [data, setData] = useState();
|
||||
const [dateRange, setDateRange] = useState(getDateRange('7d'));
|
||||
const { startDate, endDate, unit } = dateRange;
|
||||
|
||||
async function loadData() {
|
||||
setData(await get(`/api/website`));
|
||||
}
|
||||
|
||||
function handleDateChange(value) {
|
||||
setDateRange(value);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
loadData();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<DateFilter onChange={handleDateChange} />
|
||||
{data &&
|
||||
data.websites.map(({ website_id, label }) => (
|
||||
<div>
|
||||
<h2>{label}</h2>
|
||||
<WebsiteStats
|
||||
websiteId={website_id}
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
unit={unit}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue