Skip to content

Commit

Permalink
Edit button states.
Browse files Browse the repository at this point in the history
  • Loading branch information
briancao committed Aug 14, 2023
1 parent f7eeaa6 commit 96d7478
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 12 additions & 5 deletions components/pages/reports/ReportsTable.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useState } from 'react';
import { Flexbox, Icon, Icons, Text, Button, Modal } from 'react-basics';
import ConfirmDeleteForm from 'components/common/ConfirmDeleteForm';
import LinkButton from 'components/common/LinkButton';
import SettingsTable from 'components/common/SettingsTable';
import ConfirmDeleteForm from 'components/common/ConfirmDeleteForm';
import { useMessages } from 'hooks';
import useUser from 'hooks/useUser';
import { useState } from 'react';
import { Button, Flexbox, Icon, Icons, Modal, Text } from 'react-basics';

export function ReportsTable({
data = [],
Expand All @@ -16,6 +17,7 @@ export function ReportsTable({
}) {
const [report, setReport] = useState(null);
const { formatMessage, labels } = useMessages();
const { user } = useUser();

const domainColumn = [
{
Expand Down Expand Up @@ -49,14 +51,19 @@ export function ReportsTable({
filterValue={filterValue}
>
{row => {
const { id } = row;
const {
id,
userId: reportOwnerId,
website: { domain, userId: websiteOwnerId },
} = row;
if (showDomain) {
row.domain = row.website.domain;
row.domain = domain;
}

return (
<Flexbox gap={10}>
<LinkButton href={`/reports/${id}`}>{formatMessage(labels.view)}</LinkButton>
{!showDomain || user.id === reportOwnerId || user.id === websiteOwnerId}
<Button onClick={() => setReport(row)}>
<Icon>
<Icons.Trash />
Expand Down
1 change: 1 addition & 0 deletions queries/admin/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export async function getReportsByUserId(
website: {
select: {
domain: true,
userId: true,
},
},
},
Expand Down

0 comments on commit 96d7478

Please sign in to comment.