umami/src/app/(main)/teams/[teamId]/settings/websites/TeamWebsitesPage.tsx

31 lines
1 KiB
TypeScript
Raw Normal View History

2024-02-06 04:29:00 +00:00
'use client';
import { TeamContext } from 'app/(main)/teams/[teamId]/TeamProvider';
import WebsiteAddButton from 'app/(main)/settings/websites/WebsiteAddButton';
import { useLogin, useMessages } from 'components/hooks';
2024-02-06 04:29:00 +00:00
import PageHeader from 'components/layout/PageHeader';
import TeamWebsitesDataTable from './TeamWebsitesDataTable';
import { ROLES } from 'lib/constants';
import { useContext } from 'react';
2024-02-06 04:29:00 +00:00
2024-02-06 07:59:33 +00:00
export function TeamWebsitesPage({ teamId }: { teamId: string }) {
const team = useContext(TeamContext);
2024-02-06 04:29:00 +00:00
const { formatMessage, labels } = useMessages();
const { user } = useLogin();
2024-02-23 06:21:11 +00:00
const canEdit =
!!team?.teamUser?.find(
({ userId, role }) => userId === user.id && role !== ROLES.teamViewOnly,
) && user.role !== ROLES.viewOnly;
2024-02-06 04:29:00 +00:00
return (
2024-02-07 04:01:38 +00:00
<>
<PageHeader title={formatMessage(labels.websites)}>
2024-02-23 06:21:11 +00:00
{canEdit && <WebsiteAddButton teamId={teamId} />}
</PageHeader>
2024-02-23 06:21:11 +00:00
<TeamWebsitesDataTable teamId={teamId} allowEdit={canEdit} />
2024-02-07 04:01:38 +00:00
</>
2024-02-06 04:29:00 +00:00
);
}
2024-02-06 07:59:33 +00:00
export default TeamWebsitesPage;