mirror of
https://github.com/umami-software/umami.git
synced 2026-02-24 06:25:43 +01:00
Renamed (app) folder to (main).
This commit is contained in:
parent
5c15778c9b
commit
c990459238
167 changed files with 48 additions and 114 deletions
61
src/app/(main)/websites/[id]/reports/WebsiteReports.js
Normal file
61
src/app/(main)/websites/[id]/reports/WebsiteReports.js
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
'use client';
|
||||
import Page from 'components/layout/Page';
|
||||
import Empty from 'components/common/Empty';
|
||||
import ReportsTable from '../../../../(main)/reports/ReportsTable';
|
||||
import { useMessages, useWebsiteReports } from 'components/hooks';
|
||||
import Link from 'next/link';
|
||||
import { Button, Flexbox, Icon, Icons, Text } from 'react-basics';
|
||||
import WebsiteHeader from '../WebsiteHeader';
|
||||
|
||||
export function WebsiteReports({ websiteId }) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const {
|
||||
reports,
|
||||
error,
|
||||
isLoading,
|
||||
deleteReport,
|
||||
filter,
|
||||
handleFilterChange,
|
||||
handlePageChange,
|
||||
handlePageSizeChange,
|
||||
} = useWebsiteReports(websiteId);
|
||||
|
||||
const hasData = (reports && reports.data.length !== 0) || filter;
|
||||
|
||||
const handleDelete = async id => {
|
||||
await deleteReport(id);
|
||||
};
|
||||
|
||||
if (isLoading || error) {
|
||||
return <Page loading={isLoading} error={error} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<WebsiteHeader websiteId={websiteId} />
|
||||
<Flexbox alignItems="center" justifyContent="end">
|
||||
<Link href={`/reports/create`}>
|
||||
<Button variant="primary">
|
||||
<Icon>
|
||||
<Icons.Plus />
|
||||
</Icon>
|
||||
<Text>{formatMessage(labels.createReport)}</Text>
|
||||
</Button>
|
||||
</Link>
|
||||
</Flexbox>
|
||||
{hasData && (
|
||||
<ReportsTable
|
||||
data={reports}
|
||||
onDelete={handleDelete}
|
||||
onFilterChange={handleFilterChange}
|
||||
onPageChange={handlePageChange}
|
||||
onPageSizeChange={handlePageSizeChange}
|
||||
filterValue={filter}
|
||||
/>
|
||||
)}
|
||||
{!hasData && <Empty />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default WebsiteReports;
|
||||
9
src/app/(main)/websites/[id]/reports/page.tsx
Normal file
9
src/app/(main)/websites/[id]/reports/page.tsx
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import WebsiteReports from './WebsiteReports';
|
||||
|
||||
export default function WebsiteReportsPage({ params: { id } }) {
|
||||
if (!id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <WebsiteReports websiteId={id} />;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue