@@ -3,6 +3,7 @@ import QuizModal from "../components/QuizModal";
33import React , { useEffect } from "react" ;
44
55import { QuizProps } from "../types" ;
6+ import Selectable from "../components/Selectable" ;
67
78const Questions : React . FC < QuizProps > = QuizProps => {
89 const navigate = useNavigate ( ) ;
@@ -20,43 +21,41 @@ const Questions: React.FC<QuizProps> = QuizProps => {
2021 < p > Points: { QuizProps . points } </ p >
2122 </ div >
2223 < h1 className = "quiz-heading" > Question { QuizProps . questionNumber } </ h1 >
23- < div className = "quiz-div " >
24+ < form className = "select- quiz-styles " >
2425 { QuizProps . chooseAnswer ? (
2526 < QuizModal { ...QuizProps . modalProps } />
2627 ) : (
27- < fieldset className = "quiz-answers-div" >
28- < legend >
29- < span className = "sr-only" >
30- Question { QuizProps . questionNumber }
31- </ span >
32- { QuizProps . currQuestion . Question }
33- </ legend >
34- < ul >
35- { QuizProps . choicesArr . length > 0 &&
36- QuizProps . choicesArr [ QuizProps . questionNumber - 1 ] . map (
37- ( choice : string , index : number ) => (
38- < li key = { index } >
39- < button
40- className = { `answers-btns ${ choice === QuizProps . selectedOption ? `answers-btns--selected` : `` } ` }
41- onClick = { ( ) => QuizProps . selectOption ( choice ) }
42- >
43- { choice }
44- </ button >
45- </ li >
46- )
47- ) }
48- </ ul >
49- < hr />
50- < button
51- className = "select-btns submit-btn"
52- style = { { opacity : QuizProps . selectedOption ? 1 : 0.5 } }
53- onClick = { ( ) => QuizProps . checkAnswer ( ) }
54- >
55- Submit
56- </ button >
57- </ fieldset >
28+ < >
29+ < fieldset className = "quiz-answers-div" >
30+ < legend >
31+ < span className = "sr-only" >
32+ Question { QuizProps . questionNumber }
33+ </ span >
34+ { QuizProps . currQuestion . Question }
35+ </ legend >
36+ </ fieldset >
37+
38+ < Selectable
39+ options = { QuizProps . choicesArr [ QuizProps . questionNumber - 1 ] }
40+ groupName = "answers"
41+ onChange = { ( choice : string ) => {
42+ QuizProps . selectOption ( choice ) ;
43+ } }
44+ />
45+
46+ < fieldset className = "quiz-answers-div" >
47+ < hr />
48+ < button
49+ className = "select-btns submit-btn"
50+ style = { { opacity : QuizProps . selectedOption ? 1 : 0.5 } }
51+ onClick = { ( ) => QuizProps . checkAnswer ( ) }
52+ >
53+ Submit
54+ </ button >
55+ </ fieldset >
56+ </ >
5857 ) }
59- </ div >
58+ </ form >
6059 </ >
6160 ) ;
6261} ;
0 commit comments