@@ -6,11 +6,13 @@ import {
6
6
DialogContentText ,
7
7
DialogTitle ,
8
8
Button ,
9
- Typography
9
+ Typography ,
10
+ MenuItem ,
11
+ Grid
10
12
} from '@material-ui/core' ;
11
13
import { makeStyles } from '@material-ui/core/styles' ;
12
14
import CircularProgress from '@material-ui/core/CircularProgress' ;
13
- import { ValidatorForm , TextValidator } from 'react-material-ui-form-validator' ;
15
+ import { ValidatorForm , TextValidator , SelectValidator } from 'react-material-ui-form-validator' ;
14
16
import { useSnackbar } from 'notistack' ;
15
17
import axios from 'axios' ;
16
18
@@ -45,6 +47,8 @@ export default function ApplyNowModal() {
45
47
46
48
const handleClickOpen = ( ) => {
47
49
setOpen ( true ) ;
50
+ formData . countryCode = '+91' ;
51
+ formData . phone = '' ;
48
52
} ;
49
53
50
54
const handleClose = ( ) => {
@@ -59,6 +63,7 @@ export default function ApplyNowModal() {
59
63
} ;
60
64
61
65
const handleSubmit = e => {
66
+ formData . phone = `${ formData . countryCode } -${ formData . phone } ` ;
62
67
setSubmitting ( 1 ) ;
63
68
e . preventDefault ( ) ;
64
69
axios ( {
@@ -77,6 +82,11 @@ export default function ApplyNowModal() {
77
82
} ) ;
78
83
} ;
79
84
85
+ const countryCodes = Array ( 100 )
86
+ . fill ( 1 )
87
+ . map ( ( x , y ) => x + y )
88
+ . reverse ( ) ;
89
+
80
90
return (
81
91
< div >
82
92
< Button
@@ -123,22 +133,44 @@ export default function ApplyNowModal() {
123
133
fullWidth
124
134
name = "email"
125
135
onChange = { handleChange }
126
- validators = { [ 'required' ] }
127
- errorMessages = { [ 'This is a required field' ] }
136
+ validators = { [ 'required' , 'isEmail' ] }
137
+ errorMessages = { [ 'This is a required field' , 'Please enter a valid email' ] }
128
138
/>
129
139
130
- < TextValidator
131
- key = "contact"
132
- className = { classes . textField }
133
- label = "WhatsApp / Contact Number "
134
- variant = "outlined"
135
- value = { formData . phone }
136
- fullWidth
137
- name = "phone"
138
- onChange = { handleChange }
139
- validators = { [ 'required' ] }
140
- errorMessages = { [ 'This is a required field' ] }
141
- />
140
+ < Grid container spacing = { 2 } justify = "space-evenly" >
141
+ < Grid item xs = { 2 } >
142
+ < SelectValidator
143
+ key = "countryCode"
144
+ className = { classes . textField }
145
+ value = { formData . countryCode }
146
+ onChange = { handleChange }
147
+ name = "countryCode"
148
+ variant = "outlined"
149
+ validators = { [ 'required' ] }
150
+ errorMessages = { [ 'Please select a country code' ] }
151
+ fullWidth
152
+ >
153
+ { countryCodes . map ( ( code ) => {
154
+ return < MenuItem value = { `+${ code } ` } > +{ code } </ MenuItem > ;
155
+ } ) }
156
+ </ SelectValidator >
157
+ </ Grid >
158
+
159
+ < Grid item xs = { 10 } >
160
+ < TextValidator
161
+ key = "contact"
162
+ className = { classes . textField }
163
+ label = "WhatsApp / Contact Number "
164
+ variant = "outlined"
165
+ value = { formData . phone }
166
+ fullWidth
167
+ name = "phone"
168
+ onChange = { handleChange }
169
+ validators = { [ 'required' , 'matchRegexp:^[+]*[(]*[+]{0,1}[0-9]{1,3}[)]{0,1}[-s./0-9]*$' ] }
170
+ errorMessages = { [ 'This is a required field' , 'Please enter a valid contact number' ] }
171
+ />
172
+ </ Grid >
173
+ </ Grid >
142
174
143
175
< TextValidator
144
176
key = "linkedIn"
@@ -149,8 +181,8 @@ export default function ApplyNowModal() {
149
181
fullWidth
150
182
name = "linkedIn"
151
183
onChange = { handleChange }
152
- validators = { [ 'required' ] }
153
- errorMessages = { [ 'This is a required field' ] }
184
+ validators = { [ 'required' , 'matchRegexp:^(http(s)?://)?([w]+.)?linkedin.com/(pub|in|profile)' ] }
185
+ errorMessages = { [ 'This is a required field' , 'Please enter a valid URL' ] }
154
186
/>
155
187
156
188
< TextValidator
@@ -166,18 +198,25 @@ export default function ApplyNowModal() {
166
198
errorMessages = { [ 'This is a required field' ] }
167
199
/>
168
200
169
- < TextValidator
201
+ < SelectValidator
170
202
key = "year"
171
203
className = { classes . textField }
172
- label = "Year"
173
- variant = "outlined"
174
204
value = { formData . year }
175
- fullWidth
176
- name = "year"
177
205
onChange = { handleChange }
206
+ name = "year"
207
+ variant = "outlined"
178
208
validators = { [ 'required' ] }
179
- errorMessages = { [ 'This is a required field' ] }
180
- />
209
+ errorMessages = { [ 'Please select a year' ] }
210
+ label = "Year"
211
+ fullWidth
212
+ >
213
+ < MenuItem value = { 1 } > 1st</ MenuItem >
214
+ < MenuItem value = { 2 } > 2nd</ MenuItem >
215
+ < MenuItem value = { 3 } > 3rd</ MenuItem >
216
+ < MenuItem value = { 4 } > 4th</ MenuItem >
217
+ < MenuItem value = { 5 } > 5th</ MenuItem >
218
+ < MenuItem value = { 6 } > 6th</ MenuItem >
219
+ </ SelectValidator >
181
220
182
221
< TextValidator
183
222
key = "college"
0 commit comments