From 8df5084703baf2b7ae416af8d8d5064cec13ee19 Mon Sep 17 00:00:00 2001 From: enes Date: Mon, 23 Dec 2024 16:39:24 +0100 Subject: [PATCH 1/3] fix(sign): always show PdfView --- src/components/PDFView/PdfMarking.tsx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/components/PDFView/PdfMarking.tsx b/src/components/PDFView/PdfMarking.tsx index f0d4f60..6346944 100644 --- a/src/components/PDFView/PdfMarking.tsx +++ b/src/components/PDFView/PdfMarking.tsx @@ -152,17 +152,15 @@ const PdfMarking = (props: PdfMarkingProps) => { centerIcon={faPen} rightIcon={faCircleInfo} > - {currentUserMarks?.length > 0 && ( - - )} + {selectedMark !== null && ( Date: Mon, 23 Dec 2024 17:44:33 +0100 Subject: [PATCH 2/3] fix(sign): allow signing without selectedMark - no currentUserMarks --- src/components/MarkFormField/index.tsx | 29 ++++++++++++-------------- src/utils/mark.ts | 18 +++++++++------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/components/MarkFormField/index.tsx b/src/components/MarkFormField/index.tsx index 99b9b7f..fde0922 100644 --- a/src/components/MarkFormField/index.tsx +++ b/src/components/MarkFormField/index.tsx @@ -17,7 +17,7 @@ interface MarkFormFieldProps { handleCurrentUserMarkChange: (mark: CurrentUserMark) => void handleSelectedMarkValueChange: (value: string) => void handleSubmit: (event: React.MouseEvent) => void - selectedMark: CurrentUserMark + selectedMark: CurrentUserMark | null selectedMarkValue: string } @@ -34,26 +34,23 @@ const MarkFormField = ({ }: MarkFormFieldProps) => { const [displayActions, setDisplayActions] = useState(true) const [complete, setComplete] = useState(false) - const isReadyToSign = () => isCurrentUserMarksComplete(currentUserMarks) || isCurrentValueLast(currentUserMarks, selectedMark, selectedMarkValue) const isCurrent = (currentMark: CurrentUserMark) => - currentMark.id === selectedMark.id && !complete + currentMark.id === selectedMark?.id && !complete const isDone = (currentMark: CurrentUserMark) => isCurrent(currentMark) ? !!selectedMarkValue : currentMark.isCompleted const findNext = () => { return ( - currentUserMarks[selectedMark.id] || + currentUserMarks[selectedMark!.id] || findNextIncompleteCurrentUserMark(currentUserMarks) ) } const handleFormSubmit = (event: React.FormEvent) => { event.preventDefault() - console.log('handle form submit runs...') - // Without this line, we lose mark values when switching - handleCurrentUserMarkChange(selectedMark) + handleCurrentUserMarkChange(selectedMark!) if (!complete) { isReadyToSign() @@ -63,15 +60,16 @@ const MarkFormField = ({ } const toggleActions = () => setDisplayActions(!displayActions) - const markLabel = getToolboxLabelByMarkType(selectedMark.mark.type) - + const markLabel = selectedMark + ? getToolboxLabelByMarkType(selectedMark.mark.type) + : '' const handleCurrentUserMarkClick = (mark: CurrentUserMark) => { setComplete(false) handleCurrentUserMarkChange(mark) } const handleSelectCompleteMark = () => { - handleCurrentUserMarkChange(selectedMark) + if (currentUserMarks.length) handleCurrentUserMarkChange(selectedMark!) setComplete(true) } @@ -106,14 +104,15 @@ const MarkFormField = ({
- {!complete && ( + {!complete && selectedMark ? (

Add {markLabel}

+ ) : ( +

Finish

)} - {complete &&

Finish

}
- {!complete && ( + {!complete && selectedMark ? (
handleFormSubmit(e)}>
- )} - - {complete && ( + ) : (