import { ProjectLink } from '@/components/links'; import { SerieIcon } from '@/components/report-chart/common/serie-icon'; import { Tooltiper } from '@/components/ui/tooltip'; import { formatDateTime, formatTime } from '@/utils/date'; import { getProfileName } from '@/utils/getters'; import type { ColumnDef } from '@tanstack/react-table'; import { isToday } from 'date-fns'; import type { IServiceProfile } from '@openpanel/db'; import { ColumnCreatedAt } from '@/components/column-created-at'; import { ProfileAvatar } from '../profile-avatar'; export function useColumns(type: 'profiles' | 'power-users') { const columns: ColumnDef[] = [ { accessorKey: 'name', header: 'Name', cell: ({ row }) => { const profile = row.original; return ( {getProfileName(profile)} ); }, }, { accessorKey: 'referrer', header: 'Referrer', cell({ row }) { const { referrer, referrer_name } = row.original.properties; const ref = referrer_name || referrer; return (
{ref}
); }, }, { accessorKey: 'country', header: 'Country', cell({ row }) { const { country, city } = row.original.properties; return (
{city}
); }, }, { accessorKey: 'os', header: 'OS', cell({ row }) { const { os } = row.original.properties; return (
{os}
); }, }, { accessorKey: 'browser', header: 'Browser', cell({ row }) { const { browser } = row.original.properties; return (
{browser}
); }, }, { accessorKey: 'model', header: 'Model', cell({ row }) { const { model, brand } = row.original.properties; return (
{brand} / {model}
); }, }, { accessorKey: 'createdAt', header: 'Last seen', size: ColumnCreatedAt.size, cell: ({ row }) => { const item = row.original; return {item.createdAt}; }, }, ]; if (type === 'power-users') { columns.unshift({ accessorKey: 'count', header: 'Events', cell: ({ row }) => { const profile = row.original; // @ts-expect-error return
{profile.count}
; }, }); } return columns; }