File tree Expand file tree Collapse file tree 1 file changed +40
-27
lines changed Expand file tree Collapse file tree 1 file changed +40
-27
lines changed Original file line number Diff line number Diff line change @@ -325,33 +325,46 @@ const QuizForm: FC<Props> = ({
325325 { isThinking ? "Thinking..." : "Explain" }
326326 </ Button >
327327 ) }
328- < Button
329- type = "button"
330- intent = "primary"
331- size = "medium"
332- disabled = { currentQuestionIndex < lastIndex }
333- onClick = { ( ) => {
334- if ( ! showCorrectAnswer ) {
335- setSavedAnswers ( ( prev ) => ( {
336- ...prev ,
337- [ currentQuestionIndex ] : watchInput ,
338- } ) ) ;
339- }
340- setShowCorrectAnswer ( false ) ;
341- setExplanation ( null ) ;
342- if ( currentQuestionIndex === totalQuestions ) {
343- handleNextQuestion ( 1 ) ;
344- setLastIndex ( 1 ) ;
345- } else {
346- handleNextQuestion ( currentQuestionIndex + 1 ) ;
347- setLastIndex ( currentQuestionIndex + 1 ) ;
348- }
349- setCanGoBack ( false ) ;
350- reset ( ) ;
351- } }
352- >
353- Next Question
354- </ Button >
328+ { currentQuestionIndex < totalQuestions ? (
329+ < Button
330+ type = "button"
331+ intent = "primary"
332+ size = "medium"
333+ disabled = { currentQuestionIndex < lastIndex }
334+ onClick = { ( ) => {
335+ if ( ! showCorrectAnswer ) {
336+ setSavedAnswers ( ( prev ) => ( {
337+ ...prev ,
338+ [ currentQuestionIndex ] : watchInput ,
339+ } ) ) ;
340+ }
341+ setShowCorrectAnswer ( false ) ;
342+ setExplanation ( null ) ;
343+ if ( currentQuestionIndex === totalQuestions ) {
344+ handleNextQuestion ( 1 ) ;
345+ setLastIndex ( 1 ) ;
346+ } else {
347+ handleNextQuestion ( currentQuestionIndex + 1 ) ;
348+ setLastIndex ( currentQuestionIndex + 1 ) ;
349+ }
350+ setCanGoBack ( false ) ;
351+ reset ( ) ;
352+ } }
353+ >
354+ Next Question
355+ </ Button >
356+ ) : (
357+ < Button
358+ type = "button"
359+ intent = "primary"
360+ size = "medium"
361+ onClick = { ( ) => {
362+ window . location . href = "/" ;
363+ } }
364+ >
365+ Go Home
366+ </ Button >
367+ ) }
355368 </ div >
356369 </ form >
357370 ) ;
You can’t perform that action at this time.
0 commit comments