Skip to content

The Open Source DocuSign Alternative.

chore: tidy up

pit92b5111d7ea8
diff --git a/apps/web/src/app/(dashboard)/admin/documents/data-table-action-button.tsx b/apps/web/src/app/(dashboard)/admin/documents/data-table-action-button.tsx
index 7c1d42d2b..b1aa8efc5 100644
--- a/apps/web/src/app/(dashboard)/admin/documents/data-table-action-button.tsx
+++ b/apps/web/src/app/(dashboard)/admin/documents/data-table-action-button.tsx
@@ -2,11 +2,10 @@
import Link from 'next/link';
-import { Edit, Pencil, Share } from 'lucide-react';
+import { Edit } from 'lucide-react';
import { useSession } from 'next-auth/react';
-import { match } from 'ts-pattern';
-import { Document, DocumentStatus, Recipient, SigningStatus, User } from '@documenso/prisma/client';
+import { Document, Recipient, User } from '@documenso/prisma/client';
import { Button } from '@documenso/ui/primitives/button';
export type DataTableActionButtonProps = {
@@ -23,43 +22,12 @@ export const DataTableActionButton = ({ row }: DataTableActionButtonProps) => {
return null;
}
- const recipient = row.Recipient.find((recipient) => recipient.email === session.user.email);
-
- const isOwner = row.User.id === session.user.id;
- const isRecipient = !!recipient;
- const isDraft = row.status === DocumentStatus.DRAFT;
- const isPending = row.status === DocumentStatus.PENDING;
- const isComplete = row.status === DocumentStatus.COMPLETED;
- const isSigned = recipient?.signingStatus === SigningStatus.SIGNED;
-
- return match({
- isOwner,
- isRecipient,
- isDraft,
- isPending,
- isComplete,
- isSigned,
- })
- .with({ isOwner: true, isDraft: true }, () => (
- <Button className="w-24" asChild>
- <Link href={`/documents/${row.id}`}>
- <Edit className="-ml-1 mr-2 h-4 w-4" />
- Edit
- </Link>
- </Button>
- ))
- .with({ isRecipient: true, isPending: true, isSigned: false }, () => (
- <Button className="w-24" asChild>
- <Link href={`/sign/${recipient?.token}`}>
- <Pencil className="-ml-1 mr-2 h-4 w-4" />
- Sign
- </Link>
- </Button>
- ))
- .otherwise(() => (
- <Button className="w-24" disabled>
- <Share className="-ml-1 mr-2 h-4 w-4" />
- Share
- </Button>
- ));
+ return (
+ <Button className="w-24" asChild>
+ <Link href={`/documents/${row.id}`}>
+ <Edit className="-ml-1 mr-2 h-4 w-4" />
+ Edit
+ </Link>
+ </Button>
+ );
};
diff --git a/apps/web/src/app/(dashboard)/admin/documents/data-table-action-dropdown.tsx b/apps/web/src/app/(dashboard)/admin/documents/data-table-action-dropdown.tsx
index 72fdb4845..4788033b1 100644
--- a/apps/web/src/app/(dashboard)/admin/documents/data-table-action-dropdown.tsx
+++ b/apps/web/src/app/(dashboard)/admin/documents/data-table-action-dropdown.tsx
@@ -1,18 +1,6 @@
'use client';
-import Link from 'next/link';
-
-import {
- Copy,
- Download,
- Edit,
- History,
- MoreHorizontal,
- Pencil,
- Share,
- Trash2,
- XCircle,
-} from 'lucide-react';
+import { Copy, Download, History, MoreHorizontal, Trash2, XCircle } from 'lucide-react';
import { useSession } from 'next-auth/react';
import { getFile } from '@documenso/lib/universal/upload/get-file';
@@ -42,8 +30,6 @@ export const DataTableActionDropdown = ({ row }: DataTableActionDropdownProps) =
}
const recipient = row.Recipient.find((recipient) => recipient.email === session.user.email);
-
- const isOwner = row.User.id === session.user.id;
// const isRecipient = !!recipient;
// const isDraft = row.status === DocumentStatus.DRAFT;
// const isPending = row.status === DocumentStatus.PENDING;
diff --git a/apps/web/src/app/(dashboard)/admin/documents/page.tsx b/apps/web/src/app/(dashboard)/admin/documents/page.tsx
index 6b5a0761c..2fbbcd4dc 100644
--- a/apps/web/src/app/(dashboard)/admin/documents/page.tsx
+++ b/apps/web/src/app/(dashboard)/admin/documents/page.tsx
@@ -1,4 +1,3 @@
-import { getRequiredServerComponentSession } from '@documenso/lib/next-auth/get-server-session';
import { findDocuments } from '@documenso/lib/server-only/admin/get-all-documents';
import { DocumentsDataTable } from './data-table';
@@ -15,10 +14,6 @@ export default async function Documents({ searchParams = {} }: DocumentsPageProp
const perPage = Number(searchParams.perPage) || 20;
const results = await findDocuments({
- orderBy: {
- column: 'createdAt',
- direction: 'desc',
- },
page,
perPage,
});
diff --git a/apps/web/src/app/(dashboard)/admin/users/[id]/documents/page.tsx b/apps/web/src/app/(dashboard)/admin/users/[id]/documents/page.tsx
deleted file mode 100644
index e17dc611b..000000000
--- a/apps/web/src/app/(dashboard)/admin/users/[id]/documents/page.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-export default function UserDocuments() {
- return <h1>User docs</h1>;
-}
diff --git a/apps/web/src/app/(dashboard)/admin/users/data-table-users.tsx b/apps/web/src/app/(dashboard)/admin/users/data-table-users.tsx
index a598fc605..7c1ec0520 100644
--- a/apps/web/src/app/(dashboard)/admin/users/data-table-users.tsx
+++ b/apps/web/src/app/(dashboard)/admin/users/data-table-users.tsx
@@ -105,13 +105,7 @@ export const UsersDataTable = ({ users, perPage, page, totalPages }: UsersDataTa
header: 'Documents',
accessorKey: 'documents',
cell: ({ row }) => {
- return (
- <div>
- <Link href={`/admin/users/${row.original.id}/documents`}>
- {row.original.Document.length}
- </Link>
- </div>
- );
+ return <div>{row.original.Document.length}</div>;
},
},
{
diff --git a/packages/lib/server-only/admin/get-all-documents.ts b/packages/lib/server-only/admin/get-all-documents.ts
index a1abdb186..057b00afb 100644
--- a/packages/lib/server-only/admin/get-all-documents.ts
+++ b/packages/lib/server-only/admin/get-all-documents.ts
@@ -1,25 +1,12 @@
import { prisma } from '@documenso/prisma';
-import { Document } from '@documenso/prisma/client';
export interface FindDocumentsOptions {
term?: string;
page?: number;
perPage?: number;
- orderBy?: {
- column: keyof Omit<Document, 'document'>;
- direction: 'asc' | 'desc';
- };
}
-export const findDocuments = async ({
- term,
- page = 1,
- perPage = 10,
- orderBy,
-}: FindDocumentsOptions) => {
- const orderByColumn = orderBy?.column ?? 'createdAt';
- const orderByDirection = orderBy?.direction ?? 'desc';
-
+export const findDocuments = async ({ term, page = 1, perPage = 10 }: FindDocumentsOptions) => {
const termFilters = !term
? undefined
: ({
@@ -37,7 +24,7 @@ export const findDocuments = async ({
skip: Math.max(page - 1, 0) * perPage,
take: perPage,
orderBy: {
- [orderByColumn]: orderByDirection,
+ createdAt: 'desc',
},
include: {
User: {
diff --git a/packages/ui/primitives/combobox.tsx b/packages/ui/primitives/combobox.tsx
index 6e566e188..90fdc7849 100644
--- a/packages/ui/primitives/combobox.tsx
+++ b/packages/ui/primitives/combobox.tsx
@@ -16,7 +16,7 @@ import { Popover, PopoverContent, PopoverTrigger } from '@documenso/ui/primitive
type ComboboxProps = {
listValues: string[];
- onChange: (values: string[]) => void;
+ onChange: (_values: string[]) => void;
};
const Combobox = ({ listValues, onChange }: ComboboxProps) => {