import { DataColumn, DataTable, type DataTableProps, Icon, Text } from '@umami/react-zen'; import { type ReactNode, useMemo } from 'react'; import { DateDistance } from '@/components/common/DateDistance'; import { LinkButton } from '@/components/common/LinkButton'; import { SortableLabel } from '@/components/common/SortableLabel'; import { useMessages, useNavigation, useWebsiteListChartsQuery } from '@/components/hooks'; import { SquarePen } from '@/components/icons'; import { decodePunycodeDomain } from '@/lib/format'; import { WebsiteSparkline } from './WebsiteSparkline'; export interface WebsitesTableProps extends DataTableProps { showActions?: boolean; renderLink?: (row: any) => ReactNode; } export function WebsitesTable({ showActions, renderLink, data = [], ...props }: WebsitesTableProps & { data?: any[] }) { const { t, labels } = useMessages(); const { renderUrl } = useNavigation(); const websiteIds = useMemo(() => data.map(row => row.id), [data]); const chartsQuery = useWebsiteListChartsQuery(websiteIds); const charts = chartsQuery.data?.data || {}; const isChartLoading = chartsQuery.isLoading && !chartsQuery.data; return ( } style={{ minWidth: 0 }} > {renderLink} } style={{ minWidth: 0 }} > {(row: any) => ( {decodePunycodeDomain(row.domain)} )} {`${t(labels.visitors)} (7d)`}} style={{ minWidth: 0 }} > {(row: any) => { const chart = charts[row.id]; return ( ); }} } width="180px" > {(row: any) => } {showActions && ( {(row: any) => { const websiteId = row.id; return ( ); }} )} ); }