Update show website state.

This commit is contained in:
Brian Cao 2023-08-13 22:37:04 -07:00
parent 96d74783e0
commit 743e7c0477
2 changed files with 14 additions and 9 deletions

View File

@ -3,6 +3,7 @@ import { Button, Text, Icon, Icons } from 'react-basics';
import SettingsTable from 'components/common/SettingsTable'; import SettingsTable from 'components/common/SettingsTable';
import useMessages from 'hooks/useMessages'; import useMessages from 'hooks/useMessages';
import useConfig from 'hooks/useConfig'; import useConfig from 'hooks/useConfig';
import useUser from 'hooks/useUser';
export function WebsitesTable({ export function WebsitesTable({
data = [], data = [],
@ -14,6 +15,7 @@ export function WebsitesTable({
}) { }) {
const { formatMessage, labels } = useMessages(); const { formatMessage, labels } = useMessages();
const { openExternal } = useConfig(); const { openExternal } = useConfig();
const { user } = useUser();
const teamColumns = [ const teamColumns = [
{ name: 'teamName', label: formatMessage(labels.teamName) }, { name: 'teamName', label: formatMessage(labels.teamName) },
@ -42,7 +44,7 @@ export function WebsitesTable({
const { const {
id, id,
teamWebsite, teamWebsite,
user: { username }, user: { username, id: ownerId },
} = row; } = row;
if (showTeam) { if (showTeam) {
row.teamName = teamWebsite[0]?.team.name; row.teamName = teamWebsite[0]?.team.name;
@ -51,14 +53,16 @@ export function WebsitesTable({
return ( return (
<> <>
<Link href={`/settings/websites/${id}`}> {(!showTeam || ownerId === user.id) && (
<Button> <Link href={`/settings/websites/${id}`}>
<Icon> <Button>
<Icons.Edit /> <Icon>
</Icon> <Icons.Edit />
<Text>{formatMessage(labels.edit)}</Text> </Icon>
</Button> <Text>{formatMessage(labels.edit)}</Text>
</Link> </Button>
</Link>
)}
<Link href={`/websites/${id}`} target={openExternal ? '_blank' : null}> <Link href={`/websites/${id}`} target={openExternal ? '_blank' : null}>
<Button> <Button>
<Icon> <Icon>

View File

@ -131,6 +131,7 @@ export async function getWebsitesByUserId(
user: { user: {
select: { select: {
username: true, username: true,
id: true,
}, },
}, },
}, },