1
+ import Header from "../../app/core/layouts/Header" ;
1
2
import {
2
3
Autocomplete ,
3
4
Button ,
@@ -19,17 +20,16 @@ import {
19
20
useFetcher ,
20
21
} from "@remix-run/react" ;
21
22
import { withZod } from "@remix-validated-form/with-zod" ;
22
- import { useEffect , useState } from "react" ;
23
+ import { useState } from "react" ;
23
24
import { ValidatedForm } from "remix-validated-form" ;
24
25
import { z } from "zod" ;
25
26
import { zfd } from "zod-form-data" ;
26
27
import SelectField from "~/core/components/FormFields/SelectField" ;
27
28
import LabeledTextField from "~/core/components/LabeledTextField" ;
28
29
import RegularSelect from "~/core/components/RegularSelect" ;
30
+ import { getApplicantByEmail } from "~/models/applicant.server" ;
29
31
import { getActiveUniversities } from "~/models/university.server" ;
30
32
import { requireProfile } from "~/session.server" ;
31
- import { getApplicantByEmail } from "~/models/applicant.server" ;
32
- import Header from "../../app/core/layouts/Header"
33
33
34
34
export const validator = withZod (
35
35
zfd . formData ( {
@@ -164,7 +164,8 @@ export const loader: LoaderFunction = async ({ request }) => {
164
164
} ;
165
165
166
166
export default function FormPage ( ) {
167
- const { universities, profile, applicantByEmail } = useLoaderData ( ) as LoaderData ;
167
+ const { universities, profile, applicantByEmail } =
168
+ useLoaderData ( ) as LoaderData ;
168
169
169
170
const [ selectedUniversity , setSelectedUniversity ] =
170
171
useState < UniversityValue | null > ( {
@@ -194,43 +195,79 @@ export default function FormPage() {
194
195
const searchContactsDebounced = debounce ( searchContacts , 50 ) ;
195
196
196
197
const [ startDate , setStartDate ] = useState ( getCurrentDate ( ) ) ;
197
- const [ editMode , setEditMode ] = useState ( false )
198
-
199
- const editForm = async ( ) => {
200
- if ( profile . email === applicantByEmail ?. email ) {
201
- setEditMode ( true )
202
- }
203
- }
204
-
205
- useEffect ( ( ) => {
206
- editForm ( )
207
- } )
208
198
209
199
return (
210
200
< Container >
211
- < Header title = "Applicants" applicantId = { applicantByEmail ?. id . toString ( ) } />
201
+ < Header
202
+ title = "Applicants"
203
+ applicantId = { applicantByEmail ?. id . toString ( ) }
204
+ />
212
205
< Paper sx = { { p : 2 } } >
213
206
< img src = "/HeaderImage.png" alt = "Wizeline" style = { { width : "100%" } } />
214
207
< Typography component = "div" variant = "h2" >
215
208
Application Form
216
209
</ Typography >
217
- < Typography component = "div" variant = "body1" style = { { marginBottom : "25px" , textAlign :"justify" } } >
210
+ < Typography
211
+ component = "div"
212
+ variant = "body1"
213
+ style = { { marginBottom : "25px" , textAlign : "justify" } }
214
+ >
218
215
Wizeline’s Innovation Experience Program is a 3-6 month program
219
216
designed to help students transition from the theoretical to the
220
217
practical and step into technical specialties. In this program,
221
- participants will immerse in innovation projects with Wizeline industry
222
- experts, where they can make an impact and begin a successful career in
223
- technology.
218
+ participants will immerse in innovation projects with Wizeline
219
+ industry experts, where they can make an impact and begin a successful
220
+ career in technology.
224
221
</ Typography >
225
222
< ValidatedForm
226
223
validator = { validator }
227
- action = "./createapplicant"
224
+ //action="./createapplicant"
225
+ //TODO: Maybe this is not the correct approach
226
+ action = { applicantByEmail ?. email ? "./editApplicant" : "./createapplicant" }
228
227
method = "post"
229
228
defaultValues = { {
230
- //TODO: add the selects info to edit the form
231
-
232
- gender : editMode ? applicantByEmail ?. gender : ""
233
-
229
+ personalEmail : profile . email ,
230
+ fullName : applicantByEmail ?. fullName
231
+ ? applicantByEmail ?. fullName
232
+ : profile . name ,
233
+ nationality : applicantByEmail ?. nationality ? applicantByEmail . nationality : "" ,
234
+ dayOfBirth : applicantByEmail ?. dayOfBirth ? new Date ( applicantByEmail . dayOfBirth ) . toISOString ( ) . split ( 'T' ) [ 0 ] : '' ,
235
+ gender : applicantByEmail ?. gender ? applicantByEmail ?. gender : "" ,
236
+ country : applicantByEmail ?. country ? applicantByEmail . country : "" ,
237
+ homeAddress : applicantByEmail ?. homeAddress ? applicantByEmail ?. homeAddress : "" ,
238
+ phone : applicantByEmail ?. phone ? applicantByEmail ?. phone : "" ,
239
+ university : applicantByEmail ?. universityName
240
+ ? { id : applicantByEmail ?. universityId ?? '' , name : applicantByEmail ?. universityName }
241
+ : { id : '' , name : '' } ,
242
+ universityContactId : applicantByEmail ?. universityPointOfContactId ? applicantByEmail ?. universityPointOfContactId : "" ,
243
+ universityEmail : applicantByEmail ?. universityEmail ? applicantByEmail ?. universityEmail : "" ,
244
+ emergencyContactName : applicantByEmail ?. emergencyContactName ? applicantByEmail ?. emergencyContactName : "" ,
245
+ emergencyRelationship : applicantByEmail ?. emergencyRelationship ? applicantByEmail ?. emergencyRelationship : "" ,
246
+ emergencyContactPhone : applicantByEmail ?. emergencyContactPhone ? applicantByEmail ?. emergencyContactPhone : "" ,
247
+ experience : applicantByEmail ?. experience ? applicantByEmail ?. experience : "" ,
248
+ englishLevel : applicantByEmail ?. englishLevel ? applicantByEmail ?. englishLevel : "" ,
249
+ major : applicantByEmail ?. major ? applicantByEmail ?. major : "" ,
250
+ graduationDate : applicantByEmail ?. graduationDate ? new Date ( applicantByEmail . graduationDate ) . toISOString ( ) . split ( 'T' ) [ 0 ] : '' ,
251
+ semester : applicantByEmail ?. semester ? applicantByEmail ?. semester : "" ,
252
+ interest : applicantByEmail ?. interest ? applicantByEmail ?. interest : "" ,
253
+ cvLink : applicantByEmail ?. cvLink ? applicantByEmail ?. cvLink : "" ,
254
+ interestedRoles : applicantByEmail ?. interestedRoles ? applicantByEmail ?. interestedRoles : "" ,
255
+ preferredTools : applicantByEmail ?. preferredTools ? applicantByEmail ?. preferredTools : "" ,
256
+ startDate : applicantByEmail ?. startDate ? new Date ( applicantByEmail . startDate ) . toISOString ( ) . split ( 'T' ) [ 0 ] : '' ,
257
+ endDate : applicantByEmail ?. endDate ? new Date ( applicantByEmail . endDate ) . toISOString ( ) . split ( 'T' ) [ 0 ] : '' ,
258
+ hoursPerWeek : applicantByEmail ?. hoursPerWeek
259
+ ? applicantByEmail ?. hoursPerWeek !== undefined && applicantByEmail ?. hoursPerWeek !== null
260
+ ? applicantByEmail ?. hoursPerWeek . toString ( )
261
+ : ""
262
+ : "" ,
263
+ howDidYouHearAboutUs : applicantByEmail ?. howDidYouHearAboutUs ? applicantByEmail ?. howDidYouHearAboutUs : "" ,
264
+ participatedAtWizeline : applicantByEmail ?. participatedAtWizeline !== undefined
265
+ ? applicantByEmail . participatedAtWizeline
266
+ ? 'Yes'
267
+ : 'No'
268
+ : '' ,
269
+ wizelinePrograms : applicantByEmail ?. wizelinePrograms ? applicantByEmail ?. wizelinePrograms : "" ,
270
+ comments : applicantByEmail ?. comments ? applicantByEmail ?. comments : "" ,
234
271
} }
235
272
>
236
273
< Grid container spacing = { 10 } >
@@ -242,14 +279,12 @@ export default function FormPage() {
242
279
fullWidth
243
280
type = "email"
244
281
style = { { marginBottom : "20px" } }
245
- defaultValue = { profile ?. email }
246
282
/>
247
283
< SelectField
248
284
name = "gender"
249
285
label = "I identify as:"
250
286
options = { [ "Male" , "Female" , "Non-binary" , "Prefer not to say" ] }
251
287
style = { { width : "100%" , marginBottom : "20px" } }
252
-
253
288
/>
254
289
< LabeledTextField
255
290
label = "Full Name"
@@ -258,7 +293,6 @@ export default function FormPage() {
258
293
fullWidth
259
294
type = "text"
260
295
style = { { marginBottom : "20px" } }
261
- defaultValue = { profile . name }
262
296
/>
263
297
< LabeledTextField
264
298
label = "Nationality"
@@ -267,7 +301,6 @@ export default function FormPage() {
267
301
fullWidth
268
302
type = "text"
269
303
style = { { marginBottom : "20px" } }
270
- defaultValue = { editMode ? applicantByEmail ?. nationality : '' }
271
304
/>
272
305
< SelectField
273
306
name = "country"
@@ -281,15 +314,13 @@ export default function FormPage() {
281
314
"Vietnam" ,
282
315
] }
283
316
style = { { width : "100%" , marginBottom : "20px" } }
284
- // value={editMode ? applicantByEmail?.country : ''}
285
317
/>
286
318
< LabeledTextField
287
- name = "dayOfBirth"
288
319
label = "Date of birth"
320
+ name = "dayOfBirth"
289
321
fullWidth
290
322
type = "date"
291
323
style = { { marginBottom : "20px" } }
292
-
293
324
/>
294
325
< LabeledTextField
295
326
label = "Home adress"
@@ -298,7 +329,6 @@ export default function FormPage() {
298
329
fullWidth
299
330
type = "text"
300
331
style = { { marginBottom : "20px" } }
301
- defaultValue = { editMode ? applicantByEmail ?. homeAddress : '' }
302
332
/>
303
333
< LabeledTextField
304
334
label = "Phone number"
@@ -307,7 +337,6 @@ export default function FormPage() {
307
337
fullWidth
308
338
type = "text"
309
339
style = { { marginBottom : "20px" } }
310
- defaultValue = { editMode ? applicantByEmail ?. phone : '' }
311
340
/>
312
341
< Typography
313
342
component = "div"
@@ -324,7 +353,6 @@ export default function FormPage() {
324
353
label = "University or organization you belong to"
325
354
onChange = { handleSelectUniversity }
326
355
style = { { width : "100%" , marginBottom : "20px" } }
327
-
328
356
/>
329
357
330
358
< input
@@ -370,7 +398,6 @@ export default function FormPage() {
370
398
fullWidth
371
399
type = "email"
372
400
style = { { marginBottom : "20px" } }
373
- defaultValue = { editMode ? ( applicantByEmail ?. universityEmail ?? '' ) : '' }
374
401
/>
375
402
< LabeledTextField
376
403
label = "Name of contact in case of emergency"
@@ -379,7 +406,6 @@ export default function FormPage() {
379
406
fullWidth
380
407
type = "text"
381
408
style = { { marginBottom : "20px" } }
382
- defaultValue = { editMode ? ( applicantByEmail ?. emergencyContactName ?? '' ) : '' }
383
409
/>
384
410
< SelectField
385
411
name = "emergencyRelationship"
@@ -397,7 +423,6 @@ export default function FormPage() {
397
423
"Wife" ,
398
424
] }
399
425
style = { { width : "100%" , marginBottom : "20px" } }
400
- // value={editMode ? (applicantByEmail?.emergencyRelationship ?? '') : ''}
401
426
/>
402
427
< LabeledTextField
403
428
label = "Emergency phone number"
@@ -406,7 +431,6 @@ export default function FormPage() {
406
431
fullWidth
407
432
type = "text"
408
433
style = { { marginBottom : "20px" } }
409
- defaultValue = { editMode ? ( applicantByEmail ?. emergencyContactPhone ?? '' ) : '' }
410
434
/>
411
435
< LabeledTextField
412
436
label = "Professional Experience"
@@ -417,7 +441,6 @@ export default function FormPage() {
417
441
multiline
418
442
rows = { 2 }
419
443
style = { { marginBottom : "20px" } }
420
- defaultValue = { editMode ? applicantByEmail ?. experience : '' }
421
444
/>
422
445
</ Grid >
423
446
< Grid item xs = { 6 } >
@@ -431,7 +454,6 @@ export default function FormPage() {
431
454
"Proficient (C1,C2)" ,
432
455
] }
433
456
style = { { width : "100%" , marginBottom : "20px" } }
434
- // value={editMode ? applicantByEmail?.englishLevel : ''}
435
457
/>
436
458
< LabeledTextField
437
459
label = "Degree and field you are studying"
@@ -440,7 +462,6 @@ export default function FormPage() {
440
462
fullWidth
441
463
type = "text"
442
464
style = { { marginBottom : "20px" } }
443
- defaultValue = { editMode ? applicantByEmail ?. major : '' }
444
465
/>
445
466
< LabeledTextField
446
467
label = "Semester or period you will be studying while this program runs"
@@ -449,7 +470,6 @@ export default function FormPage() {
449
470
fullWidth
450
471
type = "text"
451
472
style = { { marginBottom : "20px" } }
452
- defaultValue = { editMode ? applicantByEmail ?. semester : '' }
453
473
/>
454
474
< LabeledTextField
455
475
label = "Graduation date"
@@ -467,7 +487,6 @@ export default function FormPage() {
467
487
multiline
468
488
rows = { 2 }
469
489
style = { { marginBottom : "20px" } }
470
- defaultValue = { editMode ? applicantByEmail ?. interest : '' }
471
490
/>
472
491
< LabeledTextField
473
492
label = "Link to your CV or LinkedIn profile"
@@ -476,7 +495,6 @@ export default function FormPage() {
476
495
fullWidth
477
496
type = "text"
478
497
style = { { marginBottom : "20px" } }
479
- defaultValue = { editMode ? applicantByEmail ?. cvLink : '' }
480
498
/>
481
499
< SelectField
482
500
name = "interestedRoles"
@@ -492,7 +510,6 @@ export default function FormPage() {
492
510
"Project Management" ,
493
511
] }
494
512
style = { { width : "100%" , marginBottom : "20px" } }
495
- // value={editMode ? (applicantByEmail?.interestedRoles ?? '') : ''}
496
513
/>
497
514
< LabeledTextField
498
515
label = "Preferred tools, programs, frameworks, programming languages or libraries"
@@ -503,7 +520,6 @@ export default function FormPage() {
503
520
multiline
504
521
rows = { 2 }
505
522
style = { { marginBottom : "20px" } }
506
- defaultValue = { editMode ? ( applicantByEmail ?. preferredTools ?? '' ) : '' }
507
523
/>
508
524
< LabeledTextField
509
525
label = "Preferred start date"
@@ -536,7 +552,6 @@ export default function FormPage() {
536
552
fullWidth
537
553
type = "number"
538
554
style = { { marginBottom : "20px" } }
539
- defaultValue = { editMode ? ( applicantByEmail ?. hoursPerWeek !== undefined && applicantByEmail ?. hoursPerWeek !== null ? applicantByEmail ?. hoursPerWeek . toString ( ) : '' ) : '' }
540
555
/>
541
556
< SelectField
542
557
name = "howDidYouHearAboutUs"
@@ -548,14 +563,12 @@ export default function FormPage() {
548
563
"University talk" ,
549
564
] }
550
565
style = { { width : "100%" , marginBottom : "20px" } }
551
- // value={editMode ? applicantByEmail?.howDidYouHearAboutUs : ''}
552
566
/>
553
567
< SelectField
554
568
name = "participatedAtWizeline"
555
569
label = "Have you participated in any program at Wizeline before?"
556
- options = { [ " Yes" , "No" ] }
570
+ options = { [ ' Yes' , 'No' ] }
557
571
style = { { width : "100%" , marginBottom : "20px" } }
558
- // value={editMode ? (applicantByEmail?.participatedAtWizeline ? 'true' : 'false') : ''}
559
572
/>
560
573
< SelectField
561
574
name = "wizelinePrograms"
@@ -568,7 +581,6 @@ export default function FormPage() {
568
581
"Does not apply" ,
569
582
] }
570
583
style = { { width : "100%" , marginBottom : "20px" } }
571
- // value={editMode ? (applicantByEmail?.wizelinePrograms ?? '') : ''}
572
584
/>
573
585
< LabeledTextField
574
586
label = "Any additional comments?"
@@ -578,7 +590,6 @@ export default function FormPage() {
578
590
multiline
579
591
rows = { 2 }
580
592
style = { { marginBottom : "20px" } }
581
- defaultValue = { editMode ? ( applicantByEmail ?. comments ?? '' ) : '' }
582
593
/>
583
594
< FormControlLabel
584
595
control = { < Checkbox name = "confirmRegistration" required /> }
0 commit comments