import { ReactNode, useContext } from 'react'; import Link from 'next/link'; import { Button, Text, Icon, Icons, GridTable, GridColumn, useBreakpoint } from 'react-basics'; import useMessages from 'components/hooks/useMessages'; import useUser from 'components/hooks/useUser'; import SettingsContext from '../SettingsContext'; export interface WebsitesTableProps { data: any[]; showTeam?: boolean; showActions?: boolean; allowEdit?: boolean; allowView?: boolean; children?: ReactNode; } export function WebsitesTable({ data = [], showTeam, showActions, allowEdit, allowView, children, }: WebsitesTableProps) { const { formatMessage, labels } = useMessages(); const { user } = useUser(); const breakpoint = useBreakpoint(); const { settingsPath, websitesPath } = useContext(SettingsContext); return ( {showTeam && ( {row => row.teamWebsite[0]?.team.name} )} {showTeam && ( {row => row.user.username} )} {showActions && ( {row => { const { id, user: { id: ownerId }, } = row; return ( <> {allowEdit && (!showTeam || ownerId === user.id) && ( )} {allowView && ( )} ); }} )} {children} ); } export default WebsitesTable;