@@ -6,8 +6,12 @@ import StepLabel from '@material-ui/core/StepLabel';
66import StepContent from '@material-ui/core/StepContent' ;
77import Paper from '@material-ui/core/Paper' ;
88
9- import { Button , Typography } from '@material-ui/core' ;
10- import { ValidatorForm , TextValidator } from 'react-material-ui-form-validator' ;
9+ import { Button , Typography , MenuItem } from '@material-ui/core' ;
10+ import {
11+ ValidatorForm ,
12+ TextValidator ,
13+ SelectValidator
14+ } from 'react-material-ui-form-validator' ;
1115
1216// import axios from 'axios';
1317
@@ -26,12 +30,16 @@ const useStyles = makeStyles(theme => ({
2630 padding : theme . spacing ( 3 )
2731 } ,
2832 textField : {
29- marginBottom : '12px '
33+ marginBottom : '16px '
3034 }
3135} ) ) ;
3236
3337function getSteps ( ) {
34- return [ 'Profile Information' , 'Education Information' , 'Application Challenge' ] ;
38+ return [
39+ 'Profile Information' ,
40+ 'Education Information' ,
41+ 'Application Challenge'
42+ ] ;
3543}
3644
3745function getStepContent ( step , setActiveStep , formData , setFormData ) {
@@ -67,16 +75,16 @@ function getStepContent(step, setActiveStep, formData, setFormData) {
6775
6876export function ApplicationSteps ( ) {
6977 const classes = useStyles ( ) ;
70- const [ activeStep , setActiveStep ] = React . useState ( 0 ) ;
78+ const [ activeStep , setActiveStep ] = React . useState ( 2 ) ;
7179 const [ formData , setFormData ] = React . useState ( {
72- personal : { } ,
73- education : { } ,
80+ personal : { } ,
81+ education : { } ,
7482 challenge : { }
7583 } ) ;
7684 const steps = getSteps ( ) ;
7785
7886 const handleSubmitApplication = ( ) => {
79- console . log ( formData )
87+ console . log ( formData ) ;
8088 } ;
8189
8290 return (
@@ -126,16 +134,29 @@ function FormPersonalInfo({ setActiveStep, data, setData }) {
126134 return (
127135 < ValidatorForm onSubmit = { handleSubmit } >
128136 < TextValidator
129- key = "name "
137+ key = "fullName "
130138 className = { classes . textField }
131- label = "Full Name"
139+ label = "Name"
132140 variant = "outlined"
133- value = { formData . name }
141+ value = { formData . fullName }
134142 fullWidth
135- name = "name "
143+ name = "fullName "
136144 onChange = { handleChange }
137145 validators = { [ 'required' ] }
138- errorMessages = { [ 'This is a required field' ] }
146+ errorMessages = { [ 'Name is a required field' ] }
147+ />
148+
149+ < TextValidator
150+ key = "phone"
151+ className = { classes . textField }
152+ label = "Phone"
153+ variant = "outlined"
154+ value = { formData . phone }
155+ fullWidth
156+ name = "phone"
157+ onChange = { handleChange }
158+ validators = { [ 'required' ] }
159+ errorMessages = { [ 'Phone number is a required field' ] }
139160 />
140161
141162 < TextValidator
@@ -147,10 +168,30 @@ function FormPersonalInfo({ setActiveStep, data, setData }) {
147168 fullWidth
148169 name = "email"
149170 onChange = { handleChange }
150- validators = { [ 'required' ] }
151- errorMessages = { [ 'This is a required field' ] }
171+ validators = { [ 'required' , 'isEmail' ] }
172+ errorMessages = { [
173+ 'Email is a required field' ,
174+ 'Must be a valid Email address'
175+ ] }
152176 />
153177
178+ < SelectValidator
179+ key = "gender"
180+ className = { classes . textField }
181+ value = { formData . gender }
182+ onChange = { handleChange }
183+ name = "gender"
184+ variant = "outlined"
185+ validators = { [ 'required' ] }
186+ errorMessages = { [ 'Please select a gender' ] }
187+ label = "Gender"
188+ fullWidth
189+ >
190+ < MenuItem value = "male" > Male</ MenuItem >
191+ < MenuItem value = "female" > Female</ MenuItem >
192+ < MenuItem value = "other" > Other</ MenuItem >
193+ </ SelectValidator >
194+
154195 < Button variant = "outlined" disabled color = "secondary" >
155196 Cancel
156197 </ Button >
@@ -163,7 +204,7 @@ function FormPersonalInfo({ setActiveStep, data, setData }) {
163204 marginLeft : '16px'
164205 } }
165206 >
166- Next
207+ Save
167208 </ Button >
168209 </ ValidatorForm >
169210 ) ;
@@ -193,32 +234,66 @@ function FormEducationInfo({ setActiveStep, data, setData }) {
193234 setActiveStep ( 2 ) ;
194235 } ;
195236
237+ const years = Array ( 25 )
238+ . fill ( 2000 )
239+ . map ( ( x , y ) => x + y ) ;
240+
196241 return (
197242 < ValidatorForm onSubmit = { handleSubmit } >
243+ < SelectValidator
244+ key = "year"
245+ className = { classes . textField }
246+ value = { formData . year }
247+ onChange = { handleChange }
248+ name = "year"
249+ variant = "outlined"
250+ validators = { [ 'required' ] }
251+ errorMessages = { [ 'Please select your Graduation Year' ] }
252+ label = "Graduation Year"
253+ fullWidth
254+ >
255+ { years . map ( ( year , index ) => {
256+ return < MenuItem value = { year } > { year } </ MenuItem > ;
257+ } ) }
258+ </ SelectValidator >
259+
198260 < TextValidator
199- key = "name "
261+ key = "college "
200262 className = { classes . textField }
201- label = "Full Name "
263+ label = "College "
202264 variant = "outlined"
203- value = { formData . name }
265+ value = { formData . college }
204266 fullWidth
205- name = "name "
267+ name = "college "
206268 onChange = { handleChange }
207269 validators = { [ 'required' ] }
208- errorMessages = { [ 'This is a required field' ] }
270+ errorMessages = { [ 'College is a required field' ] }
209271 />
210272
211273 < TextValidator
212- key = "email "
274+ key = "state "
213275 className = { classes . textField }
214- label = "Email "
276+ label = "State "
215277 variant = "outlined"
216- value = { formData . email }
278+ value = { formData . state }
217279 fullWidth
218- name = "email "
280+ name = "state "
219281 onChange = { handleChange }
220282 validators = { [ 'required' ] }
221- errorMessages = { [ 'This is a required field' ] }
283+ errorMessages = { [ 'State is a required field' ] }
284+ />
285+
286+ < TextValidator
287+ key = "country"
288+ className = { classes . textField }
289+ label = "Country"
290+ variant = "outlined"
291+ value = { formData . country }
292+ fullWidth
293+ name = "country"
294+ onChange = { handleChange }
295+ validators = { [ 'required' ] }
296+ errorMessages = { [ 'Country is a required field' ] }
222297 />
223298
224299 < Button variant = "outlined" onClick = { handlePrev } color = "secondary" >
@@ -232,7 +307,7 @@ function FormEducationInfo({ setActiveStep, data, setData }) {
232307 marginLeft : '16px'
233308 } }
234309 >
235- Next
310+ Save
236311 </ Button >
237312 </ ValidatorForm >
238313 ) ;
@@ -265,29 +340,33 @@ function FormChallenge({ setActiveStep, data, setData }) {
265340 return (
266341 < ValidatorForm onSubmit = { handleSubmit } >
267342 < TextValidator
268- key = "name"
269343 className = { classes . textField }
270- label = "Full Name"
271- variant = "outlined"
272- value = { formData . name }
344+ multiline
273345 fullWidth
274- name = "name"
346+ label = "Why ?"
347+ variant = "outlined"
275348 onChange = { handleChange }
276- validators = { [ 'required' ] }
277- errorMessages = { [ 'This is a required field' ] }
349+ rows = { 4 }
278350 />
279351
280352 < TextValidator
281- key = "email"
282353 className = { classes . textField }
283- label = "Email"
354+ multiline
355+ fullWidth
356+ label = "What is your expectation from this course?"
284357 variant = "outlined"
285- value = { formData . email }
358+ onChange = { handleChange }
359+ rows = { 4 }
360+ />
361+
362+ < TextValidator
363+ className = { classes . textField }
364+ multiline
286365 fullWidth
287- name = "email"
366+ label = "What is your viewpoint toward Coding in Community Contribution?"
367+ variant = "outlined"
288368 onChange = { handleChange }
289- validators = { [ 'required' ] }
290- errorMessages = { [ 'This is a required field' ] }
369+ rows = { 4 }
291370 />
292371
293372 < Button variant = "outlined" onClick = { handlePrev } color = "secondary" >
@@ -301,7 +380,7 @@ function FormChallenge({ setActiveStep, data, setData }) {
301380 marginLeft : '16px'
302381 } }
303382 >
304- Next
383+ Save
305384 </ Button >
306385 </ ValidatorForm >
307386 ) ;
0 commit comments