From 551918ab9b6fa6037a3585c5d85d5e8b98fcbfd7 Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Tue, 5 Sep 2023 13:53:18 +0000 Subject: [PATCH 01/12] feat: redirect signed document to completed page --- apps/web/src/app/(signing)/sign/[token]/page.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/web/src/app/(signing)/sign/[token]/page.tsx b/apps/web/src/app/(signing)/sign/[token]/page.tsx index 35621068a..a55687196 100644 --- a/apps/web/src/app/(signing)/sign/[token]/page.tsx +++ b/apps/web/src/app/(signing)/sign/[token]/page.tsx @@ -1,4 +1,4 @@ -import { notFound } from 'next/navigation'; +import { notFound, redirect } from 'next/navigation'; import { match } from 'ts-pattern'; @@ -44,6 +44,10 @@ export default async function SigningPage({ params: { token } }: SigningPageProp return notFound(); } + if (document?.status === 'COMPLETED') { + redirect(`/sign/${token}/complete`); + } + const user = await getServerComponentSession(); const documentUrl = `data:application/pdf;base64,${document.document}`; From a74374e39f07c0001d63de356a3f8395b25b400a Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Wed, 6 Sep 2023 11:11:13 +0000 Subject: [PATCH 02/12] feat: add initial empty state for no results --- apps/web/src/app/(dashboard)/documents/page.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/web/src/app/(dashboard)/documents/page.tsx b/apps/web/src/app/(dashboard)/documents/page.tsx index 4ea55936b..3c4c13e30 100644 --- a/apps/web/src/app/(dashboard)/documents/page.tsx +++ b/apps/web/src/app/(dashboard)/documents/page.tsx @@ -1,5 +1,7 @@ import Link from 'next/link'; +import { CheckCircle2 } from 'lucide-react'; + import { getRequiredServerComponentSession } from '@documenso/lib/next-auth/get-server-session'; import { findDocuments } from '@documenso/lib/server-only/document/find-documents'; import { getStats } from '@documenso/lib/server-only/document/get-stats'; @@ -95,8 +97,21 @@ export default async function DocumentsPage({ searchParams = {} }: DocumentsPage
- + {results.count > 0 && } + {results.count === 0 && }
); } + +const EmptyDocumentState = () => { + return ( +
+ +
+

All done

+

All documents signed for now.

+
+
+ ); +}; From 8220b2f086d1a422adfd643c0acf836c64321161 Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Wed, 6 Sep 2023 11:47:58 +0000 Subject: [PATCH 03/12] feat: add empty state for different status --- .../app/(dashboard)/documents/empty-state.tsx | 46 +++++++++++++++++++ .../src/app/(dashboard)/documents/page.tsx | 17 +------ 2 files changed, 48 insertions(+), 15 deletions(-) create mode 100644 apps/web/src/app/(dashboard)/documents/empty-state.tsx diff --git a/apps/web/src/app/(dashboard)/documents/empty-state.tsx b/apps/web/src/app/(dashboard)/documents/empty-state.tsx new file mode 100644 index 000000000..fef3af5cc --- /dev/null +++ b/apps/web/src/app/(dashboard)/documents/empty-state.tsx @@ -0,0 +1,46 @@ +import { ArrowRight, CheckCircle2 } from 'lucide-react'; + +export default function EmptyDocumentState({ status }: { status: string }) { + let headerText = 'All done'; + let bodyText = 'All documents signed for now.'; + let extraText = ''; + let showArrow = false; + + switch (status) { + case 'COMPLETED': + headerText = 'Nothing here'; + bodyText = 'There are no signed documents yet.'; + extraText = 'Start by adding a document'; + showArrow = true; + break; + case 'DRAFT': + headerText = 'Nothing here'; + bodyText = 'There are no drafts yet.'; + extraText = 'Start by adding a document'; + showArrow = true; + break; + case 'ALL': + headerText = 'Nothing here'; + bodyText = 'There are no documents yet.'; + extraText = 'Start by adding a document'; + showArrow = true; + break; + default: + break; + } + + return ( +
+ +
+

{headerText}

+

{bodyText}

+ {extraText && ( +

+ {extraText} {showArrow && } +

+ )} +
+
+ ); +} diff --git a/apps/web/src/app/(dashboard)/documents/page.tsx b/apps/web/src/app/(dashboard)/documents/page.tsx index 3c4c13e30..0a90d1535 100644 --- a/apps/web/src/app/(dashboard)/documents/page.tsx +++ b/apps/web/src/app/(dashboard)/documents/page.tsx @@ -1,7 +1,5 @@ import Link from 'next/link'; -import { CheckCircle2 } from 'lucide-react'; - import { getRequiredServerComponentSession } from '@documenso/lib/next-auth/get-server-session'; import { findDocuments } from '@documenso/lib/server-only/document/find-documents'; import { getStats } from '@documenso/lib/server-only/document/get-stats'; @@ -15,6 +13,7 @@ import { DocumentStatus } from '~/components/formatter/document-status'; import { UploadDocument } from '../dashboard/upload-document'; import { DocumentsDataTable } from './data-table'; +import EmptyDocumentState from './empty-state'; export type DocumentsPageProps = { searchParams?: { @@ -98,20 +97,8 @@ export default async function DocumentsPage({ searchParams = {} }: DocumentsPage
{results.count > 0 && } - {results.count === 0 && } + {results.count === 0 && }
); } - -const EmptyDocumentState = () => { - return ( -
- -
-

All done

-

All documents signed for now.

-
-
- ); -}; From 1ba7767f8e7675aa81d4799e1e59dd2d1a73750f Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Wed, 6 Sep 2023 11:52:15 +0000 Subject: [PATCH 04/12] chore: correct types on component --- apps/web/src/app/(dashboard)/documents/empty-state.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/web/src/app/(dashboard)/documents/empty-state.tsx b/apps/web/src/app/(dashboard)/documents/empty-state.tsx index fef3af5cc..680f67bf5 100644 --- a/apps/web/src/app/(dashboard)/documents/empty-state.tsx +++ b/apps/web/src/app/(dashboard)/documents/empty-state.tsx @@ -1,6 +1,10 @@ import { ArrowRight, CheckCircle2 } from 'lucide-react'; -export default function EmptyDocumentState({ status }: { status: string }) { +import { ExtendedDocumentStatus } from '@documenso/prisma/types/extended-document-status'; + +export type EmptyDocumentProps = { status: ExtendedDocumentStatus }; + +export default function EmptyDocumentState({ status }: EmptyDocumentProps) { let headerText = 'All done'; let bodyText = 'All documents signed for now.'; let extraText = ''; From 1f027d75d3b85e4ff403ecc6f1581258634e26b4 Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Wed, 6 Sep 2023 11:55:02 +0000 Subject: [PATCH 05/12] chore: fix eslint errors --- .../lib/server-only/pdf/insert-field-in-pdf.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/lib/server-only/pdf/insert-field-in-pdf.ts b/packages/lib/server-only/pdf/insert-field-in-pdf.ts index 61726f53c..e7b1e7c5a 100644 --- a/packages/lib/server-only/pdf/insert-field-in-pdf.ts +++ b/packages/lib/server-only/pdf/insert-field-in-pdf.ts @@ -50,10 +50,10 @@ export const insertFieldInPDF = async (pdf: PDFDocument, field: FieldWithSignatu let imageWidth = image.width; let imageHeight = image.height; - const initialDimensions = { - width: imageWidth, - height: imageHeight, - }; + // const initialDimensions = { + // width: imageWidth, + // height: imageHeight, + // }; const scalingFactor = Math.min(fieldWidth / imageWidth, fieldHeight / imageHeight, 1); @@ -76,10 +76,10 @@ export const insertFieldInPDF = async (pdf: PDFDocument, field: FieldWithSignatu let textWidth = font.widthOfTextAtSize(field.customText, fontSize); const textHeight = font.heightAtSize(fontSize); - const initialDimensions = { - width: textWidth, - height: textHeight, - }; + // const initialDimensions = { + // width: textWidth, + // height: textHeight, + // }; const scalingFactor = Math.min(fieldWidth / textWidth, fieldHeight / textHeight, 1); From f6e49e3f2143c428710c96c0c8df2af85b94ad15 Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Wed, 6 Sep 2023 12:00:23 +0000 Subject: [PATCH 06/12] chore: remove code from different branch --- apps/web/src/app/(signing)/sign/[token]/page.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apps/web/src/app/(signing)/sign/[token]/page.tsx b/apps/web/src/app/(signing)/sign/[token]/page.tsx index a55687196..f25183968 100644 --- a/apps/web/src/app/(signing)/sign/[token]/page.tsx +++ b/apps/web/src/app/(signing)/sign/[token]/page.tsx @@ -44,10 +44,6 @@ export default async function SigningPage({ params: { token } }: SigningPageProp return notFound(); } - if (document?.status === 'COMPLETED') { - redirect(`/sign/${token}/complete`); - } - const user = await getServerComponentSession(); const documentUrl = `data:application/pdf;base64,${document.document}`; From 0c145fab0bff601d5ce1cdcca042cd5248b99ed9 Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Wed, 6 Sep 2023 12:01:30 +0000 Subject: [PATCH 07/12] chore: fix eslint errors --- apps/web/src/app/(signing)/sign/[token]/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/app/(signing)/sign/[token]/page.tsx b/apps/web/src/app/(signing)/sign/[token]/page.tsx index f25183968..35621068a 100644 --- a/apps/web/src/app/(signing)/sign/[token]/page.tsx +++ b/apps/web/src/app/(signing)/sign/[token]/page.tsx @@ -1,4 +1,4 @@ -import { notFound, redirect } from 'next/navigation'; +import { notFound } from 'next/navigation'; import { match } from 'ts-pattern'; From 73b0dc315e77a750df232cdf4364495eeb45f071 Mon Sep 17 00:00:00 2001 From: Lucas Smith Date: Sat, 9 Sep 2023 03:31:17 +0000 Subject: [PATCH 08/12] fix: use ts-pattern --- .../app/(dashboard)/documents/empty-state.tsx | 55 +++++++++---------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/apps/web/src/app/(dashboard)/documents/empty-state.tsx b/apps/web/src/app/(dashboard)/documents/empty-state.tsx index 680f67bf5..a7d25a208 100644 --- a/apps/web/src/app/(dashboard)/documents/empty-state.tsx +++ b/apps/web/src/app/(dashboard)/documents/empty-state.tsx @@ -1,41 +1,40 @@ import { ArrowRight, CheckCircle2 } from 'lucide-react'; +import { match } from 'ts-pattern'; import { ExtendedDocumentStatus } from '@documenso/prisma/types/extended-document-status'; export type EmptyDocumentProps = { status: ExtendedDocumentStatus }; export default function EmptyDocumentState({ status }: EmptyDocumentProps) { - let headerText = 'All done'; - let bodyText = 'All documents signed for now.'; - let extraText = ''; - let showArrow = false; - - switch (status) { - case 'COMPLETED': - headerText = 'Nothing here'; - bodyText = 'There are no signed documents yet.'; - extraText = 'Start by adding a document'; - showArrow = true; - break; - case 'DRAFT': - headerText = 'Nothing here'; - bodyText = 'There are no drafts yet.'; - extraText = 'Start by adding a document'; - showArrow = true; - break; - case 'ALL': - headerText = 'Nothing here'; - bodyText = 'There are no documents yet.'; - extraText = 'Start by adding a document'; - showArrow = true; - break; - default: - break; - } + const { headerText, bodyText, extraText, showArrow } = match(status) + .with(ExtendedDocumentStatus.COMPLETED, () => ({ + headerText: 'Nothing here', + bodyText: 'There are no signed documents yet.', + extraText: 'Start by adding a document', + showArrow: true, + })) + .with(ExtendedDocumentStatus.DRAFT, () => ({ + headerText: 'Nothing here', + bodyText: 'There are no drafts yet.', + extraText: 'Start by adding a document', + showArrow: true, + })) + .with(ExtendedDocumentStatus.ALL, () => ({ + headerText: 'Nothing here', + bodyText: 'There are no documents yet.', + extraText: 'Start by adding a document', + showArrow: true, + })) + .otherwise(() => ({ + headerText: 'All done', + bodyText: 'All documents signed for now.', + extraText: '', + showArrow: false, + })); return (
- +

{headerText}

{bodyText}

From 2bad1b9f558430fd337d443e6229c14a0b906104 Mon Sep 17 00:00:00 2001 From: Lucas Smith Date: Sat, 9 Sep 2023 03:45:15 +0000 Subject: [PATCH 09/12] fix: tidy messaging --- .../app/(dashboard)/documents/empty-state.tsx | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/apps/web/src/app/(dashboard)/documents/empty-state.tsx b/apps/web/src/app/(dashboard)/documents/empty-state.tsx index a7d25a208..181f31fa5 100644 --- a/apps/web/src/app/(dashboard)/documents/empty-state.tsx +++ b/apps/web/src/app/(dashboard)/documents/empty-state.tsx @@ -1,4 +1,4 @@ -import { ArrowRight, CheckCircle2 } from 'lucide-react'; +import { ArrowRight, Bird, CheckCircle2 } from 'lucide-react'; import { match } from 'ts-pattern'; import { ExtendedDocumentStatus } from '@documenso/prisma/types/extended-document-status'; @@ -6,43 +6,44 @@ import { ExtendedDocumentStatus } from '@documenso/prisma/types/extended-documen export type EmptyDocumentProps = { status: ExtendedDocumentStatus }; export default function EmptyDocumentState({ status }: EmptyDocumentProps) { - const { headerText, bodyText, extraText, showArrow } = match(status) + const { + title, + message, + icon: Icon, + } = match(status) .with(ExtendedDocumentStatus.COMPLETED, () => ({ - headerText: 'Nothing here', - bodyText: 'There are no signed documents yet.', - extraText: 'Start by adding a document', - showArrow: true, + title: 'Nothing to do', + message: + 'There are no completed documents yet. Documents that you have created or received that become completed will appear here later.', + icon: CheckCircle2, })) .with(ExtendedDocumentStatus.DRAFT, () => ({ - headerText: 'Nothing here', - bodyText: 'There are no drafts yet.', - extraText: 'Start by adding a document', - showArrow: true, + title: 'No active drafts', + message: + 'There are no active drafts at then current moment. You can upload a document to start drafting.', + icon: CheckCircle2, })) .with(ExtendedDocumentStatus.ALL, () => ({ - headerText: 'Nothing here', - bodyText: 'There are no documents yet.', - extraText: 'Start by adding a document', - showArrow: true, + title: "We're all empty", + message: + 'You have not yet created or received any documents. To create a document please upload one.', + icon: Bird, })) .otherwise(() => ({ - headerText: 'All done', - bodyText: 'All documents signed for now.', - extraText: '', - showArrow: false, + title: 'Nothing to do', + message: + 'All documents are currently actioned. Any new documents are sent or recieved they will start to appear here.', + icon: CheckCircle2, })); return ( -
- +
+ +
-

{headerText}

-

{bodyText}

- {extraText && ( -

- {extraText} {showArrow && } -

- )} +

{title}

+ +

{message}

); From 946b2fe1290df6fd29c813436256591c5fc74e61 Mon Sep 17 00:00:00 2001 From: Lucas Smith Date: Fri, 22 Sep 2023 23:15:30 +1000 Subject: [PATCH 10/12] fix: use named export --- apps/web/src/app/(dashboard)/documents/empty-state.tsx | 2 +- apps/web/src/app/(dashboard)/documents/page.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/src/app/(dashboard)/documents/empty-state.tsx b/apps/web/src/app/(dashboard)/documents/empty-state.tsx index 181f31fa5..e8ce9073b 100644 --- a/apps/web/src/app/(dashboard)/documents/empty-state.tsx +++ b/apps/web/src/app/(dashboard)/documents/empty-state.tsx @@ -5,7 +5,7 @@ import { ExtendedDocumentStatus } from '@documenso/prisma/types/extended-documen export type EmptyDocumentProps = { status: ExtendedDocumentStatus }; -export default function EmptyDocumentState({ status }: EmptyDocumentProps) { +export const EmptyDocumentState = ({ status }: EmptyDocumentProps) => { const { title, message, diff --git a/apps/web/src/app/(dashboard)/documents/page.tsx b/apps/web/src/app/(dashboard)/documents/page.tsx index 8e5a82708..9ae16e44b 100644 --- a/apps/web/src/app/(dashboard)/documents/page.tsx +++ b/apps/web/src/app/(dashboard)/documents/page.tsx @@ -12,7 +12,7 @@ import { PeriodSelectorValue } from '~/components/(dashboard)/period-selector/ty import { DocumentStatus } from '~/components/formatter/document-status'; import { DocumentsDataTable } from './data-table'; -import EmptyDocumentState from './empty-state'; +import { EmptyDocumentState } from './empty-state'; import { UploadDocument } from './upload-document'; export type DocumentsPageProps = { From 201ba65e1cb96235ec81dbc3cec3d529ab20f520 Mon Sep 17 00:00:00 2001 From: Lucas Smith Date: Fri, 22 Sep 2023 23:23:55 +1000 Subject: [PATCH 11/12] fix: remove unused import --- apps/web/src/app/(dashboard)/documents/empty-state.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/app/(dashboard)/documents/empty-state.tsx b/apps/web/src/app/(dashboard)/documents/empty-state.tsx index e8ce9073b..62ba381d4 100644 --- a/apps/web/src/app/(dashboard)/documents/empty-state.tsx +++ b/apps/web/src/app/(dashboard)/documents/empty-state.tsx @@ -1,4 +1,4 @@ -import { ArrowRight, Bird, CheckCircle2 } from 'lucide-react'; +import { Bird, CheckCircle2 } from 'lucide-react'; import { match } from 'ts-pattern'; import { ExtendedDocumentStatus } from '@documenso/prisma/types/extended-document-status'; From 43ce76d92899e3faa47a90b53c79e9fdec252784 Mon Sep 17 00:00:00 2001 From: Lucas Smith Date: Fri, 22 Sep 2023 23:29:14 +1000 Subject: [PATCH 12/12] fix: remove unused import --- apps/web/src/app/(dashboard)/documents/empty-state.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/app/(dashboard)/documents/empty-state.tsx b/apps/web/src/app/(dashboard)/documents/empty-state.tsx index 62ba381d4..bdfef3bbe 100644 --- a/apps/web/src/app/(dashboard)/documents/empty-state.tsx +++ b/apps/web/src/app/(dashboard)/documents/empty-state.tsx @@ -47,4 +47,4 @@ export const EmptyDocumentState = ({ status }: EmptyDocumentProps) => {
); -} +};