diff --git a/apps/web/components/editor/pdf-editor.tsx b/apps/web/components/editor/pdf-editor.tsx index 003b912e3..ae28f4a7f 100644 --- a/apps/web/components/editor/pdf-editor.tsx +++ b/apps/web/components/editor/pdf-editor.tsx @@ -6,10 +6,11 @@ import { Button } from "@documenso/ui"; import short from "short-uuid"; import toast from "react-hot-toast"; import { FieldType } from "@prisma/client"; -import { Listbox, Transition } from "@headlessui/react"; +import { Listbox, RadioGroup, Transition } from "@headlessui/react"; import { CheckIcon, ChevronUpDownIcon } from "@heroicons/react/24/outline"; import { classNames } from "@documenso/lib"; import Draggable from "react-draggable"; +import Logo from "../logo"; const stc = require("string-to-color"); const PDFViewer = dynamic(() => import("./pdf-viewer"), { @@ -22,13 +23,22 @@ export default function PDFEditor(props: any) { ); const noRecipients = props?.document?.Recipient?.length === 0; const [fields, setFields] = useState(props.document.Field); + const [adding, setAdding] = useState(false); const router = useRouter(); + const fieldTypes = [ + { name: "Signature" }, + { name: "Text" }, + { name: "Date" }, + ]; + const [selectedFieldType, setSelectedFieldType] = useState( + fieldTypes[0].name + ); function onPositionChangedHandler(position: any, id: any) { if (!position) return; const movedField = fields.find((e) => e.id == id); - movedField.positionX = position.x; - movedField.positionY = position.y; + movedField.positionX = position.x.toFixed(0); + movedField.positionY = position.y.toFixed(0); upsertField(props.document, movedField); // no instant redraw neccessary, postion information for saving or later rerender is enough @@ -50,150 +60,188 @@ export default function PDFEditor(props: any) { return ( <> - { - var rect = e.target.getBoundingClientRect(); - var newFieldX = e.clientX - rect.left; //x position within the element. - var newFieldY = e.clientY - rect.top; //y position within the element. - const signatureField = { - id: -1, - page: page, - type: FieldType.SIGNATURE, - positionX: newFieldX.toFixed(0), - positionY: newFieldY.toFixed(0), - Recipient: selectedRecipient, - }; - - upsertField(props?.document, signatureField).then((res) => { - setFields(fields.concat(res)); - }); - }} - > -