From 84e3d29589d72d0b43c7884f8ff58174197f3208 Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Sun, 16 Apr 2023 18:29:40 +0000 Subject: [PATCH 1/4] Use documenso as container name for local development --- docker/compose-without-app.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/compose-without-app.yml b/docker/compose-without-app.yml index 8f10c2a5b..e0b566e96 100644 --- a/docker/compose-without-app.yml +++ b/docker/compose-without-app.yml @@ -1,6 +1,8 @@ +name: documenso services: database: image: postgres:15 + container_name: database environment: - POSTGRES_USER=documenso - POSTGRES_PASSWORD=password @@ -10,6 +12,7 @@ services: inbucket: image: inbucket/inbucket + container_name: mailserver ports: - 9000:9000 - 2500:2500 From bcc2530484c0064eae6ed29f8318b7cab27016d1 Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Sun, 16 Apr 2023 23:45:57 +0000 Subject: [PATCH 2/4] Declutter Textarea by removing placeholders --- apps/web/pages/documents/[id]/recipients.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/web/pages/documents/[id]/recipients.tsx b/apps/web/pages/documents/[id]/recipients.tsx index fefa9a27a..de20e22e1 100644 --- a/apps/web/pages/documents/[id]/recipients.tsx +++ b/apps/web/pages/documents/[id]/recipients.tsx @@ -175,7 +175,6 @@ const RecipientsPage: NextPageWithLayout = (props: any) => { }); }} className="block w-full border-0 bg-inherit p-0 text-gray-900 placeholder-gray-500 outline-none disabled:bg-neutral-100 sm:text-sm" - placeholder="john.dorian@loremipsum.com" /> {errors?.signers?.[index] ? (

@@ -213,7 +212,6 @@ const RecipientsPage: NextPageWithLayout = (props: any) => { }); }} className="block w-full border-0 bg-inherit p-0 text-gray-900 placeholder-gray-500 outline-none disabled:bg-neutral-100 sm:text-sm" - placeholder="John Dorian" /> From 80d26adf9c131cbe5ccd5b63a60a99586cc17f76 Mon Sep 17 00:00:00 2001 From: Saurav Gurhale Date: Sun, 16 Apr 2023 16:02:20 -0400 Subject: [PATCH 3/4] add toast error for invalid email --- apps/web/pages/documents/[id]/recipients.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/web/pages/documents/[id]/recipients.tsx b/apps/web/pages/documents/[id]/recipients.tsx index de20e22e1..180940ef8 100644 --- a/apps/web/pages/documents/[id]/recipients.tsx +++ b/apps/web/pages/documents/[id]/recipients.tsx @@ -20,6 +20,7 @@ import { } from "@heroicons/react/24/outline"; import { DocumentStatus, Document as PrismaDocument } from "@prisma/client"; import { FormProvider, useFieldArray, useForm, useWatch } from "react-hook-form"; +import { toast } from "react-hot-toast"; export type FormValues = { signers: { id: number; email: string; name: string }[]; @@ -108,7 +109,9 @@ const RecipientsPage: NextPageWithLayout = (props: any) => { color="primary" icon={PaperAirplaneIcon} onClick={() => { - setOpen(true); + formValues.some((r: any) => r.email && hasEmailError(r)) + ? toast.error("Please enter a valid email address.", { id: "invalid email" }) + : setOpen(true); }} disabled={ (formValues.length || 0) === 0 || From 70ea3ceaf3952b32d1ee21e6a3c3c1efe06dad2e Mon Sep 17 00:00:00 2001 From: Mythie Date: Wed, 19 Apr 2023 23:56:19 +1000 Subject: [PATCH 4/4] fix: improve types --- apps/web/pages/documents/[id]/recipients.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/web/pages/documents/[id]/recipients.tsx b/apps/web/pages/documents/[id]/recipients.tsx index 180940ef8..8dc9e7f64 100644 --- a/apps/web/pages/documents/[id]/recipients.tsx +++ b/apps/web/pages/documents/[id]/recipients.tsx @@ -18,14 +18,16 @@ import { UserPlusIcon, XMarkIcon, } from "@heroicons/react/24/outline"; -import { DocumentStatus, Document as PrismaDocument } from "@prisma/client"; +import { DocumentStatus, Document as PrismaDocument, Recipient } from "@prisma/client"; import { FormProvider, useFieldArray, useForm, useWatch } from "react-hook-form"; import { toast } from "react-hot-toast"; export type FormValues = { - signers: { id: number; email: string; name: string }[]; + signers: Array>; }; +type FormSigner = FormValues["signers"][number]; + const RecipientsPage: NextPageWithLayout = (props: any) => { const title: string = `"` + props?.document?.title + `"` + "Recipients | Documenso"; const breadcrumbItems = [ @@ -64,7 +66,7 @@ const RecipientsPage: NextPageWithLayout = (props: any) => { }); const formValues = useWatch({ control, name: "signers" }); const cancelButtonRef = useRef(null); - const hasEmailError = (formValue: any): boolean => { + const hasEmailError = (formValue: FormSigner): boolean => { const index = formValues.findIndex((e) => e.id === formValue.id); return !!errors?.signers?.[index]?.email; }; @@ -109,14 +111,14 @@ const RecipientsPage: NextPageWithLayout = (props: any) => { color="primary" icon={PaperAirplaneIcon} onClick={() => { - formValues.some((r: any) => r.email && hasEmailError(r)) + formValues.some((r) => r.email && hasEmailError(r)) ? toast.error("Please enter a valid email address.", { id: "invalid email" }) : setOpen(true); }} disabled={ (formValues.length || 0) === 0 || !formValues.some( - (r: any) => r.email && !hasEmailError(r) && r.sendStatus === "NOT_SENT" + (r) => r.email && !hasEmailError(r) && r.sendStatus === "NOT_SENT" ) || loading }> @@ -141,7 +143,7 @@ const RecipientsPage: NextPageWithLayout = (props: any) => { trigger(); }}>