Skip to content

The Open Source DocuSign Alternative.

Merge branch 'main' into feat/download-toast

Lucas Smith419f27536b2d
diff --cc apps/web/src/app/(dashboard)/documents/data-table-action-button.tsx
index 3fc9e2d42,4e63c4475..fb10888de
--- a/apps/web/src/app/(dashboard)/documents/data-table-action-button.tsx
+++ b/apps/web/src/app/(dashboard)/documents/data-table-action-button.tsx
@@@ -39,46 -37,39 +39,47 @@@ export const DataTableActionButton = (
const isSigned = recipient?.signingStatus === SigningStatus.SIGNED;
const onDownloadClick = async () => {
- let document: DocumentWithData | null = null;
+ try {
+ let document: DocumentWithData | null = null;
- if (!recipient) {
- document = await trpcClient.document.getDocumentById.query({
- id: row.id,
- });
- } else {
- document = await trpcClient.document.getDocumentByToken.query({
- token: recipient.token,
- });
- }
+ if (!recipient) {
+ document = await trpcClient.document.getDocumentById.query({
+ id: row.id,
+ });
+ } else {
+ document = await trpcClient.document.getDocumentByToken.query({
+ token: recipient.token,
+ });
+ }
- const documentData = document?.documentData;
+ const documentData = document?.documentData;
- if (!documentData) {
- return;
- }
+ if (!documentData) {
+ return;
+ }
- const documentBytes = await getFile(documentData);
+ const documentBytes = await getFile(documentData);
- const blob = new Blob([documentBytes], {
- type: 'application/pdf',
- });
+ const blob = new Blob([documentBytes], {
+ type: 'application/pdf',
+ });
- const link = window.document.createElement('a');
- const baseTitle = row.title.includes('.pdf') ? row.title.split('.pdf')[0] : row.title;
+ const link = window.document.createElement('a');
++ const baseTitle = row.title.includes('.pdf') ? row.title.split('.pdf')[0] : row.title;
- link.href = window.URL.createObjectURL(blob);
- link.download = baseTitle ? `${baseTitle}_signed.pdf` : 'document.pdf';
+ link.href = window.URL.createObjectURL(blob);
- link.download = row.title || 'document.pdf';
++ link.download = baseTitle ? `${baseTitle}_signed.pdf` : 'document.pdf';
- link.click();
+ link.click();
- window.URL.revokeObjectURL(link.href);
+ window.URL.revokeObjectURL(link.href);
+ } catch (error) {
+ toast({
+ title: 'Something went wrong',
+ description: 'An error occurred while trying to download file.',
+ variant: 'destructive',
+ });
+ }
};
return match({