'use client'; import { useTransition } from 'react'; import Link from 'next/link'; import { AlertTriangle, Globe2Icon, InfoIcon, Link2Icon, Loader, LockIcon } 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 { FindTemplateRow } from '@documenso/lib/server-only/template/find-templates'; 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 { Tooltip, TooltipContent, TooltipTrigger } from '@documenso/ui/primitives/tooltip'; 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 { TemplateDirectLinkBadge } from './template-direct-link-badge'; import { UseTemplateDialog } from './use-template-dialog'; type TemplatesDataTableProps = { templates: FindTemplateRow[]; 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
  • Public

    Public templates are connected to your public profile. Any modifications to public templates will also appear in your public profile.

  • direct link

    Direct link templates contain one dynamic recipient placeholder. Anyone with access to this link can sign the document, and it will then appear on your documents page.

  • {teamId ? 'Team Only' : 'Private'}

    {teamId ? 'Team only templates are not linked anywhere and are visible only to your team.' : 'Private templates can only be modified and viewed by you.'}

), accessorKey: 'type', cell: ({ row }) => (
{row.original.directLink?.token && ( )}
), }, { header: 'Actions', accessorKey: 'actions', cell: ({ row }) => { return (
); }, }, ]} data={templates} perPage={perPage} currentPage={page} totalPages={totalPages} onPaginationChange={onPaginationChange} > {(table) => }
{isPending && (
)}
); };