'use client'; import { useTransition } from 'react'; import Link from 'next/link'; import { AlertTriangle, Loader } from 'lucide-react'; import { useLimits } from '@documenso/ee/server-only/limits/provider/client'; import { useUpdateSearchParams } from '@documenso/lib/client-only/hooks/use-update-search-params'; import type { Recipient, Template } from '@documenso/prisma/client'; import { Alert, AlertDescription, AlertTitle } from '@documenso/ui/primitives/alert'; import { DataTable } from '@documenso/ui/primitives/data-table'; import { DataTablePagination } from '@documenso/ui/primitives/data-table-pagination'; import { LocaleDate } from '~/components/formatter/locale-date'; import { TemplateType } from '~/components/formatter/template-type'; import { DataTableActionDropdown } from './data-table-action-dropdown'; import { DataTableTitle } from './data-table-title'; import { UseTemplateDialog } from './use-template-dialog'; type TemplateWithRecipient = Template & { Recipient: Recipient[]; }; type TemplatesDataTableProps = { templates: Array< TemplateWithRecipient & { team: { id: number; url: string } | null; } >; perPage: number; page: number; totalPages: number; documentRootPath: string; templateRootPath: string; teamId?: number; }; export const TemplatesDataTable = ({ templates, perPage, page, totalPages, documentRootPath, templateRootPath, teamId, }: TemplatesDataTableProps) => { const [isPending, startTransition] = useTransition(); const updateSearchParams = useUpdateSearchParams(); const { remaining } = useLimits(); const onPaginationChange = (page: number, perPage: number) => { startTransition(() => { updateSearchParams({ page, perPage, }); }); }; return (
{remaining.documents === 0 && ( Document Limit Exceeded! You have reached your document limit.{' '} Upgrade your account to continue! )} , }, { header: 'Title', cell: ({ row }) => , }, { header: 'Type', accessorKey: 'type', cell: ({ row }) => , }, { header: 'Actions', accessorKey: 'actions', cell: ({ row }) => { return (
); }, }, ]} data={templates} perPage={perPage} currentPage={page} totalPages={totalPages} onPaginationChange={onPaginationChange} > {(table) => }
{isPending && (
)}
); };