diff options
Diffstat (limited to 'src/app/(main)/websites/WebsitesTable.tsx')
| -rw-r--r-- | src/app/(main)/websites/WebsitesTable.tsx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/app/(main)/websites/WebsitesTable.tsx b/src/app/(main)/websites/WebsitesTable.tsx new file mode 100644 index 0000000..70648ed --- /dev/null +++ b/src/app/(main)/websites/WebsitesTable.tsx @@ -0,0 +1,41 @@ +import { DataColumn, DataTable, type DataTableProps, Icon } from '@umami/react-zen'; +import type { ReactNode } from 'react'; +import { LinkButton } from '@/components/common/LinkButton'; +import { useMessages, useNavigation } from '@/components/hooks'; +import { SquarePen } from '@/components/icons'; + +export interface WebsitesTableProps extends DataTableProps { + showActions?: boolean; + allowEdit?: boolean; + allowView?: boolean; + renderLink?: (row: any) => ReactNode; +} + +export function WebsitesTable({ showActions, renderLink, ...props }: WebsitesTableProps) { + const { formatMessage, labels } = useMessages(); + const { renderUrl } = useNavigation(); + + return ( + <DataTable {...props}> + <DataColumn id="name" label={formatMessage(labels.name)}> + {renderLink} + </DataColumn> + <DataColumn id="domain" label={formatMessage(labels.domain)} /> + {showActions && ( + <DataColumn id="action" label=" " align="end"> + {(row: any) => { + const websiteId = row.id; + + return ( + <LinkButton href={renderUrl(`/websites/${websiteId}/settings`)} variant="quiet"> + <Icon> + <SquarePen /> + </Icon> + </LinkButton> + ); + }} + </DataColumn> + )} + </DataTable> + ); +} |