chore: implemented feedback
This commit is contained in:
@@ -1,95 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import { Copy, Download, History, MoreHorizontal, Trash2, XCircle } from 'lucide-react';
|
|
||||||
|
|
||||||
import { getFile } from '@documenso/lib/universal/upload/get-file';
|
|
||||||
import { Document, DocumentStatus, User } from '@documenso/prisma/client';
|
|
||||||
import { DocumentWithData } from '@documenso/prisma/types/document-with-data';
|
|
||||||
import { trpc } from '@documenso/trpc/client';
|
|
||||||
import {
|
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuLabel,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from '@documenso/ui/primitives/dropdown-menu';
|
|
||||||
|
|
||||||
export type DataTableActionDropdownProps = {
|
|
||||||
row: Document & {
|
|
||||||
User: Pick<User, 'id' | 'name' | 'email'>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const DataTableActionDropdown = ({ row }: DataTableActionDropdownProps) => {
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
const onDownloadClick = async () => {
|
|
||||||
let document: DocumentWithData | null = null;
|
|
||||||
|
|
||||||
document = await trpc.document.getDocumentById.query({
|
|
||||||
id: row.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
const documentData = document?.documentData;
|
|
||||||
|
|
||||||
if (!documentData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const documentBytes = await getFile(documentData);
|
|
||||||
|
|
||||||
const blob = new Blob([documentBytes], {
|
|
||||||
type: 'application/pdf',
|
|
||||||
});
|
|
||||||
|
|
||||||
const link = window.document.createElement('a');
|
|
||||||
|
|
||||||
link.href = window.URL.createObjectURL(blob);
|
|
||||||
link.download = row.title || 'document.pdf';
|
|
||||||
|
|
||||||
link.click();
|
|
||||||
|
|
||||||
window.URL.revokeObjectURL(link.href);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger>
|
|
||||||
<MoreHorizontal className="h-5 w-5 text-gray-500" />
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
|
|
||||||
<DropdownMenuContent className="w-52" align="start" forceMount>
|
|
||||||
<DropdownMenuLabel>Action</DropdownMenuLabel>
|
|
||||||
|
|
||||||
<DropdownMenuItem disabled={!isComplete} onClick={onDownloadClick}>
|
|
||||||
<Download className="mr-2 h-4 w-4" />
|
|
||||||
Download
|
|
||||||
</DropdownMenuItem>
|
|
||||||
|
|
||||||
<DropdownMenuItem disabled>
|
|
||||||
<Copy className="mr-2 h-4 w-4" />
|
|
||||||
Duplicate
|
|
||||||
</DropdownMenuItem>
|
|
||||||
|
|
||||||
<DropdownMenuItem disabled>
|
|
||||||
<XCircle className="mr-2 h-4 w-4" />
|
|
||||||
Void
|
|
||||||
</DropdownMenuItem>
|
|
||||||
|
|
||||||
<DropdownMenuItem disabled>
|
|
||||||
<Trash2 className="mr-2 h-4 w-4" />
|
|
||||||
Delete
|
|
||||||
</DropdownMenuItem>
|
|
||||||
|
|
||||||
<DropdownMenuItem disabled>
|
|
||||||
<History className="mr-2 h-4 w-4" />
|
|
||||||
Resend
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
|
import { Prisma } from '@documenso/prisma/client';
|
||||||
|
|
||||||
export interface FindDocumentsOptions {
|
export interface FindDocumentsOptions {
|
||||||
term?: string;
|
term?: string;
|
||||||
@@ -7,14 +8,14 @@ export interface FindDocumentsOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const findDocuments = async ({ term, page = 1, perPage = 10 }: FindDocumentsOptions) => {
|
export const findDocuments = async ({ term, page = 1, perPage = 10 }: FindDocumentsOptions) => {
|
||||||
const termFilters = !term
|
const termFilters: Prisma.DocumentWhereInput | undefined = !term
|
||||||
? undefined
|
? undefined
|
||||||
: ({
|
: {
|
||||||
title: {
|
title: {
|
||||||
contains: term,
|
contains: term,
|
||||||
mode: 'insensitive',
|
mode: 'insensitive',
|
||||||
},
|
},
|
||||||
} as const);
|
};
|
||||||
|
|
||||||
const [data, count] = await Promise.all([
|
const [data, count] = await Promise.all([
|
||||||
prisma.document.findMany({
|
prisma.document.findMany({
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Prisma } from '@prisma/client';
|
|
||||||
|
|
||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
|
import { Prisma } from '@documenso/prisma/client';
|
||||||
|
|
||||||
type GetAllUsersProps = {
|
type GetAllUsersProps = {
|
||||||
username: string;
|
username: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user