diff --git a/src/App.tsx b/src/App.tsx index 9f58f21..11434af 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -33,7 +33,7 @@ const App = () => { window.location.href.split(`${window.location.origin}/#`)[1] ) - return `${appPublicRoutes.login}?callbackPath=${callbackPathEncoded}` + return `${appPublicRoutes.landingPage}?callbackPath=${callbackPathEncoded}` } // Hide route only if loggedIn and r.hiddenWhenLoggedIn are both true 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 && ( + ) : (