Add no reports message.

This commit is contained in:
Brian Cao 2023-08-11 13:52:10 -07:00
parent 0a81a4a728
commit 5e64eac396
2 changed files with 26 additions and 12 deletions

View File

@ -246,6 +246,10 @@ export const messages = defineMessages({
id: 'message.no-websites-configured', id: 'message.no-websites-configured',
defaultMessage: 'You do not have any websites configured.', defaultMessage: 'You do not have any websites configured.',
}, },
noReportsConfigured: {
id: 'message.no-reports-configured',
defaultMessage: 'You do not have any reports configured.',
},
noTeamWebsites: { noTeamWebsites: {
id: 'message.no-team-websites', id: 'message.no-team-websites',
defaultMessage: 'This team does not have any websites.', defaultMessage: 'This team does not have any websites.',

View File

@ -1,12 +1,13 @@
import EmptyPlaceholder from 'components/common/EmptyPlaceholder';
import Page from 'components/layout/Page'; import Page from 'components/layout/Page';
import Link from 'next/link';
import { Button, Icon, Icons, Text, Flexbox } from 'react-basics';
import { useMessages, useReports } from 'hooks';
import ReportsTable from 'components/pages/reports/ReportsTable'; import ReportsTable from 'components/pages/reports/ReportsTable';
import { useMessages, useReports } from 'hooks';
import Link from 'next/link';
import { Button, Flexbox, Icon, Icons, Text } from 'react-basics';
import WebsiteHeader from './WebsiteHeader'; import WebsiteHeader from './WebsiteHeader';
export function WebsiteReportsPage({ websiteId }) { export function WebsiteReportsPage({ websiteId }) {
const { formatMessage, labels } = useMessages(); const { formatMessage, labels, messages } = useMessages();
const { const {
reports, reports,
error, error,
@ -18,6 +19,8 @@ export function WebsiteReportsPage({ websiteId }) {
handlePageSizeChange, handlePageSizeChange,
} = useReports(websiteId); } = useReports(websiteId);
const hasData = reports && reports.data.length !== 0;
const handleDelete = async id => { const handleDelete = async id => {
await deleteReport(id); await deleteReport(id);
}; };
@ -35,14 +38,21 @@ export function WebsiteReportsPage({ websiteId }) {
</Button> </Button>
</Link> </Link>
</Flexbox> </Flexbox>
<ReportsTable {hasData && (
data={reports} <ReportsTable
onDelete={handleDelete} data={reports}
onFilterChange={handleFilterChange} onDelete={handleDelete}
onPageChange={handlePageChange} onFilterChange={handleFilterChange}
onPageSizeChange={handlePageSizeChange} onPageChange={handlePageChange}
filterValue={filter} onPageSizeChange={handlePageSizeChange}
/> filterValue={filter}
/>
)}
{!hasData && (
<EmptyPlaceholder message={formatMessage(messages.noReportsConfigured)}>
{/* {addButton} */}
</EmptyPlaceholder>
)}
</Page> </Page>
); );
} }