Update language. Resolve loading reports error.

This commit is contained in:
Brian Cao 2023-08-14 10:39:24 -07:00
parent 743e7c0477
commit 5168cf2a1b
5 changed files with 14 additions and 20 deletions

View File

@ -243,15 +243,7 @@ export const messages = defineMessages({
},
noResultsFound: {
id: 'message.no-results-found',
defaultMessage: 'No results were found.',
},
noWebsitesConfigured: {
id: 'message.no-websites-configured',
defaultMessage: 'You do not have any websites configured.',
},
noReportsConfigured: {
id: 'message.no-reports-configured',
defaultMessage: 'You do not have any reports configured.',
defaultMessage: 'No results found.',
},
noTeamWebsites: {
id: 'message.no-team-websites',

View File

@ -3,7 +3,7 @@ import Page from 'components/layout/Page';
import PageHeader from 'components/layout/PageHeader';
import { useMessages, useReports } from 'hooks';
import Link from 'next/link';
import { Button, Flexbox, Icon, Icons, Text } from 'react-basics';
import { Button, Icon, Icons, Text } from 'react-basics';
import ReportsTable from './ReportsTable';
export function ReportsPage() {
@ -12,6 +12,7 @@ export function ReportsPage() {
reports,
error,
isLoading,
deleteReport,
filter,
handleFilterChange,
handlePageChange,
@ -20,6 +21,10 @@ export function ReportsPage() {
const hasData = (reports && reports?.data.length !== 0) || filter;
const handleDelete = async id => {
await deleteReport(id);
};
return (
<Page loading={isLoading} error={error}>
<PageHeader title={formatMessage(labels.reports)}>
@ -41,12 +46,13 @@ export function ReportsPage() {
onFilterChange={handleFilterChange}
onPageChange={handlePageChange}
onPageSizeChange={handlePageSizeChange}
onDelete={deleteReport}
filterValue={filter}
showDomain={true}
/>
)}
{!hasData && (
<EmptyPlaceholder message={formatMessage(messages.noReportsConfigured)}></EmptyPlaceholder>
<EmptyPlaceholder message={formatMessage(messages.noDataAvailable)}></EmptyPlaceholder>
)}
</Page>
);

View File

@ -51,19 +51,15 @@ export function ReportsTable({
filterValue={filterValue}
>
{row => {
const {
id,
userId: reportOwnerId,
website: { domain, userId: websiteOwnerId },
} = row;
const { id, userId: reportOwnerId, website } = row;
if (showDomain) {
row.domain = domain;
row.domain = website.domain;
}
return (
<Flexbox gap={10}>
<LinkButton href={`/reports/${id}`}>{formatMessage(labels.view)}</LinkButton>
{!showDomain || user.id === reportOwnerId || user.id === websiteOwnerId}
{!showDomain || user.id === reportOwnerId || user.id === website?.userId}
<Button onClick={() => setReport(row)}>
<Icon>
<Icons.Trash />

View File

@ -68,7 +68,7 @@ export function WebsitesList({ showTeam, showHeader = true, includeTeams, onlyTe
/>
)}
{!hasData && (
<EmptyPlaceholder message={formatMessage(messages.noWebsitesConfigured)}>
<EmptyPlaceholder message={formatMessage(messages.noDataAvailable)}>
{addButton}
</EmptyPlaceholder>
)}

View File

@ -48,7 +48,7 @@ export function WebsiteReportsPage({ websiteId }) {
filterValue={filter}
/>
)}
{!hasData && <EmptyPlaceholder message={formatMessage(messages.noReportsConfigured)} />}
{!hasData && <EmptyPlaceholder message={formatMessage(messages.noDataAvailable)} />}
</Page>
);
}