@@ -3,10 +3,13 @@ import { useState } from "react";
33import { useForm , SubmitHandler } from "react-hook-form" ;
44import axios from "axios" ;
55import Input from "@ui/form-elements/input" ;
6+ import Checkbox from "@ui/form-elements/checkbox" ;
7+ import TextArea from "@ui/form-elements/textarea" ;
68import Button from "@ui/button" ;
79import { hasKey } from "@utils/methods" ;
810import Feedback from "@ui/form-elements/feedback" ;
911import { linkedinRegex , githubRegex } from "@utils/formValidations" ;
12+ import { motion } from "framer-motion" ;
1013
1114interface IFormValues {
1215 firstName : string ;
@@ -19,6 +22,10 @@ interface IFormValues {
1922 branchOfService : string ;
2023 yearJoined : string ;
2124 yearSeparated : string ;
25+ hasAttendedPreviousCourse : boolean ;
26+ previousCourses : string ;
27+ willAttendAnotherCourse : boolean ;
28+ otherCourses : string ;
2229 linkedInAccountName : string ;
2330 githubAccountName : string ;
2431 preworkLink : string ;
@@ -34,8 +41,12 @@ const ApplyForm = () => {
3441 handleSubmit,
3542 formState : { errors } ,
3643 reset,
44+ watch,
3745 } = useForm < IFormValues > ( ) ;
3846
47+ const watchHasAttendedPreviousCourses = watch ( "hasAttendedPreviousCourse" , false ) ;
48+ const watchWillAttendAnotherCourse = watch ( "willAttendAnotherCourse" , false ) ;
49+
3950 const onSubmit : SubmitHandler < IFormValues > = async ( data ) => {
4051 try {
4152 await axios . post ( "/api/apply" , data ) ;
@@ -219,7 +230,67 @@ const ApplyForm = () => {
219230 } ) }
220231 />
221232 </ div >
222- < div className = "tw-mb-7.5" >
233+ < Checkbox
234+ label = "Have you previously attended any coding bootcamps or tech education programs?"
235+ id = "hasAttendedPreviousCourse"
236+ { ...register ( "hasAttendedPreviousCourse" ) }
237+ />
238+ < br />
239+ { watchHasAttendedPreviousCourses && (
240+ < motion . div
241+ layout
242+ className = "tw-mb-7.5"
243+ initial = { { opacity : 0 , scale : 0.4 } }
244+ animate = { { opacity : 1 , scale : 1 } }
245+ >
246+ < label htmlFor = "previousCourses" className = "tw-text-heading tw-text-md" >
247+ List previous courses *
248+ </ label >
249+ < TextArea
250+ id = "previousCourses"
251+ placeholder = "Javascript 101"
252+ bg = "light"
253+ feedbackText = { errors ?. previousCourses ?. message }
254+ state = { hasKey ( errors , "previousCourses" ) ? "error" : "success" }
255+ showState = { ! ! hasKey ( errors , "previousCourses" ) }
256+ { ...register ( "previousCourses" , {
257+ required : "List previous coursework or uncheck the box" ,
258+ } ) }
259+ />
260+ </ motion . div >
261+ ) }
262+ < motion . div layout >
263+ < Checkbox
264+ label = "Will you be attending any other courses or programs concurrently with Vets Who Code?"
265+ id = "willAttendAnotherCourse"
266+ { ...register ( "willAttendAnotherCourse" ) }
267+ />
268+ < br />
269+ </ motion . div >
270+ { watchWillAttendAnotherCourse && (
271+ < motion . div
272+ layout
273+ className = "tw-mb-7.5"
274+ initial = { { opacity : 0 , scale : 0.4 } }
275+ animate = { { opacity : 1 , scale : 1 } }
276+ >
277+ < label htmlFor = "otherCourses" className = "tw-text-heading tw-text-md" >
278+ List concurrent courses/programs *
279+ </ label >
280+ < TextArea
281+ id = "otherCourses"
282+ placeholder = "Civvies Who Code"
283+ bg = "light"
284+ feedbackText = { errors ?. otherCourses ?. message }
285+ state = { hasKey ( errors , "otherCourses" ) ? "error" : "success" }
286+ showState = { ! ! hasKey ( errors , "otherCourses" ) }
287+ { ...register ( "otherCourses" , {
288+ required : "List concurrent coursework or uncheck the box" ,
289+ } ) }
290+ />
291+ </ motion . div >
292+ ) }
293+ < motion . div layout className = "tw-mb-7.5" >
223294 < label htmlFor = "linkedInAccountName" className = "tw-text-heading tw-text-md" >
224295 LinkedIn Account Name *
225296 </ label >
@@ -239,8 +310,8 @@ const ApplyForm = () => {
239310 } ,
240311 } ) }
241312 />
242- </ div >
243- < div className = "tw-mb-7.5" >
313+ </ motion . div >
314+ < motion . div layout className = "tw-mb-7.5" >
244315 < label htmlFor = "githubAccountName" className = "tw-text-heading tw-text-md" >
245316 GitHub Account Name *
246317 </ label >
@@ -260,8 +331,8 @@ const ApplyForm = () => {
260331 } ,
261332 } ) }
262333 />
263- </ div >
264- < div className = "tw-mb-7.5" >
334+ </ motion . div >
335+ < motion . div layout className = "tw-mb-7.5" >
265336 < label htmlFor = "preworkLink" className = "tw-text-heading tw-text-md" >
266337 Prework Link *
267338 </ label >
@@ -276,8 +347,8 @@ const ApplyForm = () => {
276347 required : "Prework Link is required" ,
277348 } ) }
278349 />
279- </ div >
280- < div className = "tw-mb-7.5" >
350+ </ motion . div >
351+ < motion . div layout className = "tw-mb-7.5" >
281352 < label htmlFor = "preworkRepo" className = "tw-text-heading tw-text-md" >
282353 Prework Repository *
283354 </ label >
@@ -292,17 +363,19 @@ const ApplyForm = () => {
292363 required : "Prework Repository is required" ,
293364 } ) }
294365 />
295- </ div >
366+ </ motion . div >
296367
297- < Button
298- type = "submit"
299- fullwidth
300- className = "tw-mx-auto tw-w-full sm:tw-w-[200px] tw-mt-7.5"
301- >
302- Apply
303- </ Button >
304- { message && < Feedback state = "success" > { message } </ Feedback > }
305- { showEmojiRain && < EmojiRain /> }
368+ < motion . div layout >
369+ < Button
370+ type = "submit"
371+ fullwidth
372+ className = "tw-mx-auto tw-w-full sm:tw-w-[200px] tw-mt-7.5"
373+ >
374+ Apply
375+ </ Button >
376+ { message && < Feedback state = "success" > { message } </ Feedback > }
377+ { showEmojiRain && < EmojiRain /> }
378+ </ motion . div >
306379 </ form >
307380 </ div >
308381 ) ;
0 commit comments