From 676c563c2f4514860c40ce5eccca8ac94ee385ad Mon Sep 17 00:00:00 2001 From: Timur Ercan Date: Wed, 15 Feb 2023 15:44:23 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20=E2=9C=A8=20Associate=20recipien?= =?UTF-8?q?ts=20to=20fields,=20improved=20flow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/components/editor/field.tsx | 15 +- apps/web/components/editor/pdf-editor.tsx | 179 +++++++++++++----- .../pages/api/documents/[id]/fields/index.ts | 8 + apps/web/pages/documents/[id]/index.tsx | 2 +- apps/web/pages/documents/[id]/recipients.tsx | 9 + packages/features/uploadDocument.ts | 2 +- packages/lib/query/getDocument.ts | 2 +- 7 files changed, 168 insertions(+), 49 deletions(-) diff --git a/apps/web/components/editor/field.tsx b/apps/web/components/editor/field.tsx index 259a8ac0b..69dfa6ff3 100644 --- a/apps/web/components/editor/field.tsx +++ b/apps/web/components/editor/field.tsx @@ -16,7 +16,7 @@ type FieldPropsType = { positionX: number; positionY: number; id: string; - recipient: string; + Recipient: { name: ""; email: "" }; }; onPositionChanged: any; onDelete: any; @@ -53,13 +53,22 @@ export default function Field(props: FieldPropsType) { >
+
{/* todo icons */} {field.type} -
{props.field.recipient}
+ {field.type === "SIGNATURE" ? ( +
+ {`${props.field.Recipient?.name} <${props.field.Recipient?.email}>`} +
+ ) : ( + "" + )}
import("./pdf-viewer"), { ssr: false, }); export default function PDFEditor(props: any) { - const [selectedRecipient, setSelectedRecipient] = useState(""); + const [selectedRecipient, setSelectedRecipient]: any = useState( + props?.document?.Recipient[0] + ); + const noRecipients = props?.document?.Recipient?.length === 0; const [fields, setFields] = useState(props.document.Field); const router = useRouter(); @@ -43,48 +50,134 @@ export default function PDFEditor(props: any) { return ( <> - - - - - + + + {props?.document?.Recipient?.map((recipient: any) => ( + + classNames( + active ? "text-white bg-indigo-600" : "text-gray-900", + "relative cursor-default select-none py-2 pl-3 pr-9" + ) + } + value={recipient} + > + {({ selected, active }) => ( + <> +
+ + + {`${selectedRecipient?.name} <${selectedRecipient?.email}>`} + +
+ + {selected ? ( + + + ) : null} + + )} +
+ ))} +
+
+
+ )} + + + + + {
+