blob: 3f0a6b9c060fd8d64cc2f16a1519c8cf5f29ad11 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
import Link from 'next/link';
import { DataGrid } from '@/components/common/DataGrid';
import { useLoginQuery, useNavigation, useUserWebsitesQuery } from '@/components/hooks';
import { Favicon } from '@/index';
import { Icon, Row } from '@umami/react-zen';
import { WebsitesTable } from './WebsitesTable';
export function WebsitesDataTable({
userId,
teamId,
allowEdit = true,
allowView = true,
showActions = true,
}: {
userId?: string;
teamId?: string;
allowEdit?: boolean;
allowView?: boolean;
showActions?: boolean;
}) {
const { user } = useLoginQuery();
const queryResult = useUserWebsitesQuery({ userId: userId || user?.id, teamId });
const { renderUrl } = useNavigation();
const renderLink = (row: any) => (
<Row alignItems="center" gap="3">
<Icon size="md" color="muted">
<Favicon domain={row.domain} />
</Icon>
<Link href={renderUrl(`/websites/${row.id}`, false)}>{row.name}</Link>
</Row>
);
return (
<DataGrid query={queryResult} allowSearch allowPaging>
{({ data }) => (
<WebsitesTable
data={data}
showActions={showActions}
allowEdit={allowEdit}
allowView={allowView}
renderLink={renderLink}
/>
)}
</DataGrid>
);
}
|