Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.3 kB
3
Indexable
Never
 const onSubmit = () => {
        if (state.education === undefined) {
            setEducationError(true)
        }
        if (state.readingResults === undefined && !disableReading) {
            setReadingError(true)
        }
        if (state.writingResults === undefined && !disableWriting) {
            setWritingError(true)
        }
        if (state.countingResults === undefined && !disableCounting) {
            setCountingError(true)
        }
        if (selectReadingGroup === 2 && state?.readingSecondTestResults === undefined) {
            setSecondTestReadingError(true)
        }
        if (selectWritingGroup === 2 && state?.writingSecondTestResults === undefined) {
            setSecondTestWritingError(true)
        }
        if (setSelectCountingGroup === 2 && state?.countingSecondTestResults === undefined) {
            setSecondTestCountingError(true)
        }
        if (state.readingResults !== undefined || state.writingResults !== undefined || state.countingResults !== undefined || state.education !== undefined) {
            setCountingError(false)
            setWritingError(false)
            setReadingError(false)
            setEducationError(false)
        }
        if (state?.readingSecondTestResults !== undefined) {
            setSecondTestReadingError(false)
        }
        if (state?.writingSecondTestResults !== undefined) {
            setSecondTestWritingError(false)
        }
        if (state?.countingSecondTestResults !== undefined) {
            setSecondTestCountingError(false)
        }

        if ((state.education !== undefined &&
            (state.readingResults !== undefined || state.writingResults !== undefined || state.countingResults !== undefined))
            ||
            ((state.readingResults !== undefined && selectReadingGroup === 2 && state?.readingSecondTestResults !== undefined)
                ||
                (state.writingResults !== undefined && (selectWritingGroup === 2 && state?.writingSecondTestResults !== undefined))
                ||
                (state.countingResults !== undefined && (selectCountingGroup === 2 && state?.countingSecondTestResults !== undefined))
            )
        ) {
            navigate(selfAssessment ? '/funding-recomendations' : "/test-results");
        }

    }