From cb0d2dd7bc98a7e16c3d2e53fba4bd86a0c8a89d Mon Sep 17 00:00:00 2001 From: enes Date: Mon, 23 Dec 2024 17:45:13 +0100 Subject: [PATCH] fix(sign): allow sumit without selectedMark --- src/components/PDFView/PdfMarking.tsx | 45 +++++++++++++-------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/components/PDFView/PdfMarking.tsx b/src/components/PDFView/PdfMarking.tsx index 6346944..cbd3907 100644 --- a/src/components/PDFView/PdfMarking.tsx +++ b/src/components/PDFView/PdfMarking.tsx @@ -101,21 +101,22 @@ const PdfMarking = (props: PdfMarkingProps) => { */ const handleSubmit = (event: React.MouseEvent) => { event.preventDefault() - if (!selectedMarkValue || !selectedMark) return + if (selectedMarkValue && selectedMark) { + const updatedMark: CurrentUserMark = getUpdatedMark( + selectedMark, + selectedMarkValue + ) - const updatedMark: CurrentUserMark = getUpdatedMark( - selectedMark, - selectedMarkValue - ) + setSelectedMarkValue(EMPTY) + const updatedCurrentUserMarks = updateCurrentUserMarks( + currentUserMarks, + updatedMark + ) + setCurrentUserMarks(updatedCurrentUserMarks) + setSelectedMark(null) + setUpdatedMarks(updatedMark.mark) + } - setSelectedMarkValue(EMPTY) - const updatedCurrentUserMarks = updateCurrentUserMarks( - currentUserMarks, - updatedMark - ) - setCurrentUserMarks(updatedCurrentUserMarks) - setSelectedMark(null) - setUpdatedMarks(updatedMark.mark) handleSign() } @@ -162,16 +163,14 @@ const PdfMarking = (props: PdfMarkingProps) => { otherUserMarks={otherUserMarks} /> - {selectedMark !== null && ( - - )} + )