From 73cded1b4e6b63b671f05c8f2980946e1585798a Mon Sep 17 00:00:00 2001 From: Timur Ercan Date: Wed, 8 Feb 2023 16:17:55 +0100 Subject: [PATCH] sending dialog --- apps/web/pages/documents/[id]/recipients.tsx | 99 ++++++++++++++++++-- 1 file changed, 92 insertions(+), 7 deletions(-) diff --git a/apps/web/pages/documents/[id]/recipients.tsx b/apps/web/pages/documents/[id]/recipients.tsx index c3a903c0f..d54b8c16c 100644 --- a/apps/web/pages/documents/[id]/recipients.tsx +++ b/apps/web/pages/documents/[id]/recipients.tsx @@ -1,11 +1,12 @@ import Head from "next/head"; -import { ReactElement, useState } from "react"; +import { Fragment, ReactElement, useRef, useState } from "react"; import Layout from "../../../components/layout"; import { NextPageWithLayout } from "../../_app"; import { classNames, NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib"; import { CheckBadgeIcon, CheckIcon, + EnvelopeIcon, PaperAirplaneIcon, UserPlusIcon, XMarkIcon, @@ -15,6 +16,7 @@ import { getDocument } from "@documenso/lib/query"; import { Document as PrismaDocument } from "@prisma/client"; import { Breadcrumb, Button, IconButton } from "@documenso/ui"; import toast from "react-hot-toast"; +import { Dialog, Transition } from "@headlessui/react"; const RecipientsPage: NextPageWithLayout = (props: any) => { const title: string = @@ -40,6 +42,9 @@ const RecipientsPage: NextPageWithLayout = (props: any) => { const [signers, setSigners] = useState(props?.document?.Recipient); const [loading, setLoading] = useState(false); + const [open, setOpen] = useState(false); + + const cancelButtonRef = useRef(null); return ( <> @@ -62,9 +67,7 @@ const RecipientsPage: NextPageWithLayout = (props: any) => { icon={PaperAirplaneIcon} onClick={() => { setLoading(true); - send(props.document).finally(() => { - setLoading(false); - }); + setOpen(true); }} disabled={ (signers.length || 0) === 0 || @@ -108,7 +111,7 @@ const RecipientsPage: NextPageWithLayout = (props: any) => { type="email" name="email" value={item.email} - disabled={item.sendStatus === "SENT"} + disabled={item.sendStatus === "SENT" || loading} onChange={(e) => { const updatedSigners = [...signers]; updatedSigners[index].email = e.target.value; @@ -141,7 +144,7 @@ const RecipientsPage: NextPageWithLayout = (props: any) => { type="email" name="name" value={item.name} - disabled={item.sendStatus === "SENT"} + disabled={item.sendStatus === "SENT" || loading} onChange={(e) => { const updatedSigners = [...signers]; updatedSigners[index].name = e.target.value; @@ -217,7 +220,9 @@ const RecipientsPage: NextPageWithLayout = (props: any) => {
{ const signersWithoutIndex = [...signers]; const removedItem = signersWithoutIndex.splice( @@ -254,6 +259,86 @@ const RecipientsPage: NextPageWithLayout = (props: any) => {
+ + + +
+ + +
+
+ + +
+
+
+
+ + Ready to send + +
+

+ {`"${props.document.title}" will be sent to ${ + signers.filter((s: any) => s.sendStatus != "SENT") + .length + } recipients.`} +

+
+
+
+
+ + +
+
+
+
+
+
+
); };