1+ import MainLayout from './MainLayout' ;
12import React , { useState , useEffect } from 'react' ;
23import {
34 TextField ,
@@ -14,6 +15,7 @@ import {
1415} from '@mui/material' ;
1516import { useNavigate } from 'react-router-dom' ;
1617import QRCode from 'react-qr-code' ;
18+ import { purple } from '@mui/material/colors' ;
1719
1820function HomePage ( ) {
1921 const [ quizID , setQuizID ] = useState ( '' ) ;
@@ -73,84 +75,92 @@ function HomePage() {
7375 const pageURL = 'https://demo.localstack.cloud/' ;
7476
7577 return (
76- < Container maxWidth = "sm" >
77- < Typography variant = "h4" gutterBottom >
78- Enter Quiz Details
79- </ Typography >
80-
81- { errorMessage && (
82- < Alert severity = "error" sx = { { marginBottom : 2 } } >
83- { errorMessage }
84- </ Alert >
85- ) }
86-
87- { publicQuizzes . length > 0 ? (
88- < FormControl fullWidth margin = "normal" >
89- < InputLabel id = "public-quiz-label" > Select a Public Quiz</ InputLabel >
90- < Select
91- labelId = "public-quiz-label"
92- value = { selectedQuizID }
93- label = "Select a Public Quiz"
94- onChange = { handleQuizSelect }
95- >
96- { publicQuizzes . map ( ( quiz ) => (
97- < MenuItem key = { quiz . QuizID } value = { quiz . QuizID } >
98- { quiz . Title }
99- </ MenuItem >
100- ) ) }
101- </ Select >
102- </ FormControl >
103- ) : (
104- < Typography variant = "body1" gutterBottom >
105- No public quizzes are available.
78+ < MainLayout >
79+ < Container maxWidth = "sm" className = "main-quiz-container" >
80+ < Typography variant = "h4" gutterBottom >
81+ Welcome
10682 </ Typography >
107- ) }
10883
109- < TextField
110- label = "Quiz ID"
111- fullWidth
112- margin = "normal"
113- value = { quizID }
114- onChange = { handleQuizIDChange }
115- disabled = { selectedQuizID !== '' }
116- />
117- < TextField
118- label = "Username"
119- fullWidth
120- margin = "normal"
121- value = { username }
122- onChange = { ( e ) => setUsername ( e . target . value ) }
123- />
124- < TextField
125- label = "Email (Optional)"
126- fullWidth
127- margin = "normal"
128- value = { email }
129- onChange = { ( e ) => setEmail ( e . target . value ) }
130- />
84+ { errorMessage && (
85+ < Alert severity = "error" sx = { { marginBottom : 2 } } >
86+ { errorMessage }
87+ </ Alert >
88+ ) }
13189
132- < Stack spacing = { 2 } marginTop = { 4 } >
133- < Button
134- variant = "contained"
135- color = "primary"
136- onClick = { handleStart }
137- disabled = { ! quizID || ! username }
138- >
139- Start Playing
140- </ Button >
141- < Button
142- variant = "contained"
143- color = "secondary"
144- onClick = { handleCreateQuiz }
145- >
146- Create a New Quiz
147- </ Button >
148- </ Stack >
90+ { publicQuizzes . length > 0 ? (
91+ < FormControl fullWidth margin = "normal" >
92+ < InputLabel id = "public-quiz-label" > Select a Public Quiz</ InputLabel >
93+ < Select
94+ labelId = "public-quiz-label"
95+ value = { selectedQuizID }
96+ label = "Select a Public Quiz"
97+ onChange = { handleQuizSelect }
98+ >
99+ { publicQuizzes . map ( ( quiz ) => (
100+ < MenuItem key = { quiz . QuizID } value = { quiz . QuizID } >
101+ { quiz . Title }
102+ </ MenuItem >
103+ ) ) }
104+ </ Select >
105+ </ FormControl >
106+ ) : (
107+ < Typography variant = "body1" gutterBottom >
108+ No public quizzes are available.
109+ </ Typography >
110+ ) }
149111
150- < Box sx = { { marginTop : 4 , textAlign : 'center' } } >
151- < Typography variant = "h6" gutterBottom >
152- Share this Page
153- </ Typography >
112+ < TextField
113+ label = "Quiz ID"
114+ fullWidth
115+ margin = "normal"
116+ value = { quizID }
117+ onChange = { handleQuizIDChange }
118+ disabled = { selectedQuizID !== '' }
119+ />
120+ < TextField
121+ label = "Username"
122+ fullWidth
123+ margin = "normal"
124+ value = { username }
125+ onChange = { ( e ) => setUsername ( e . target . value ) }
126+ />
127+ < TextField
128+ label = "Email (Optional)"
129+ fullWidth
130+ margin = "normal"
131+ value = { email }
132+ onChange = { ( e ) => setEmail ( e . target . value ) }
133+ />
134+
135+ < Stack spacing = { 2 } >
136+ < Button
137+ variant = "contained"
138+ style = { { backgroundColor : purple [ 500 ] , color : 'white' } }
139+ onClick = { handleStart }
140+ disabled = { ! quizID || ! username }
141+ >
142+ Start Playing
143+ </ Button >
144+ < Button
145+ variant = "outlined"
146+ color = "secondary"
147+ onClick = { handleCreateQuiz }
148+ >
149+ Create a New Quiz
150+ </ Button >
151+ </ Stack >
152+ </ Container >
153+ < Box
154+ sx = { {
155+ marginTop : 4 ,
156+ textAlign : 'center' ,
157+ backgroundColor : 'white' ,
158+ width : 166 ,
159+ marginLeft : 'auto' ,
160+ marginRight : 'auto' ,
161+ borderRadius : '4px' ,
162+ } }
163+ >
154164 < Box
155165 sx = { {
156166 background : 'white' ,
@@ -160,8 +170,11 @@ function HomePage() {
160170 >
161171 < QRCode value = { pageURL } size = { 128 } />
162172 </ Box >
173+ < Typography variant = "h6" gutterBottom >
174+ Share this Page
175+ </ Typography >
163176 </ Box >
164- </ Container >
177+ </ MainLayout >
165178 ) ;
166179}
167180
0 commit comments