🚧 field positions

This commit is contained in:
Timur Ercan
2023-02-14 12:28:33 +01:00
parent 3bca832720
commit 8f17f18d0a
3 changed files with 14 additions and 7 deletions

View File

@@ -12,13 +12,14 @@ const PDFViewer = dynamic(() => import("./pdf-viewer"), {
export default function PDFEditor(props: any) {
const [selectedValue, setSelectedValue] = useState("");
const [fields, setFields] = useState<any[]>([]);
const [fields, setFields] = useState<any[]>(props.document.Field);
const router = useRouter();
function onPositionChangedHandler(position: any, id: any) {
if (!position) return;
const newFields = [...fields];
fields.find((e) => e.id == id).position = position;
fields.find((e) => e.id == id).positionX = position.x;
fields.find((e) => e.id == id).positionY = position.y;
// no instant redraw neccessary, postion information for saving or later rerender is enough
// setFields(newFields);
@@ -53,7 +54,8 @@ export default function PDFEditor(props: any) {
id: short.generate().toString(),
page: 0,
type: "signature",
position: { x: 0, y: -842 },
positionX: 0,
positionY: 0,
recipient: selectedValue,
})
);