Skip to content

Commit 573eeb8

Browse files
authored
Add application question for prior bootcamps or programs (#645)
* Add application question for prior bootcamps or programs * Add question for concurrent courses or programs * Update placeholder text
1 parent 298d08d commit 573eeb8

File tree

2 files changed

+114
-19
lines changed

2 files changed

+114
-19
lines changed

src/components/forms/apply-form.tsx

Lines changed: 90 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ import { useState } from "react";
33
import { useForm, SubmitHandler } from "react-hook-form";
44
import axios from "axios";
55
import Input from "@ui/form-elements/input";
6+
import Checkbox from "@ui/form-elements/checkbox";
7+
import TextArea from "@ui/form-elements/textarea";
68
import Button from "@ui/button";
79
import { hasKey } from "@utils/methods";
810
import Feedback from "@ui/form-elements/feedback";
911
import { linkedinRegex, githubRegex } from "@utils/formValidations";
12+
import { motion } from "framer-motion";
1013

1114
interface 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
);

src/pages/api/apply.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ interface ParsedBody {
1414
branchOfService?: string;
1515
yearJoined?: string;
1616
yearSeparated?: string;
17+
hasAttendedPreviousCourse?: boolean;
18+
previousCourses?: string;
19+
willAttendAnotherCourse?: boolean;
20+
otherCourses?: string;
1721
linkedInAccountName?: string;
1822
githubAccountName?: string;
1923
preworkLink?: string;
@@ -34,6 +38,8 @@ export default async function handler(req: Request, res: Response) {
3438
"branchOfService",
3539
"yearJoined",
3640
"yearSeparated",
41+
"hasAttendedPreviousCourse",
42+
"willAttendAnotherCourse",
3743
"linkedInAccountName",
3844
"githubAccountName",
3945
"preworkLink",
@@ -48,7 +54,7 @@ export default async function handler(req: Request, res: Response) {
4854
}
4955

5056
// Construct the text message to be sent
51-
const text = [
57+
const items = [
5258
`First Name: \`${parsedBody.firstName ?? ""}\``,
5359
`Last Name: \`${parsedBody.lastName ?? ""}\``,
5460
`Email: \`${parsedBody.email ?? ""}\``,
@@ -59,11 +65,27 @@ export default async function handler(req: Request, res: Response) {
5965
`Branch of Service: \`${parsedBody.branchOfService ?? ""}\``,
6066
`Year Joined: \`${parsedBody.yearJoined ?? ""}\``,
6167
`Year Separated: \`${parsedBody.yearSeparated ?? ""}\``,
68+
`Has attended previous bootcamp/programs: \`${
69+
parsedBody.hasAttendedPreviousCourse ? "Yes" : "No"
70+
}\``,
71+
`Will do other courses/programs concurrently: \`${
72+
parsedBody.willAttendAnotherCourse ? "Yes" : "No"
73+
}\``,
6274
`LinkedIn Account Name: \`${parsedBody.linkedInAccountName ?? ""}\``,
6375
`GitHub Account Name: \`${parsedBody.githubAccountName ?? ""}\``,
6476
`Prework Link: \`${parsedBody.preworkLink ?? ""}\``,
6577
`Prework Repository: \`${parsedBody.preworkRepo ?? ""}\``,
66-
].join("\n");
78+
];
79+
80+
if (parsedBody.willAttendAnotherCourse && parsedBody.otherCourses !== "") {
81+
items.splice(12, 0, `\`\`\`${parsedBody.otherCourses}\`\`\``);
82+
}
83+
84+
if (parsedBody.hasAttendedPreviousCourse && parsedBody.previousCourses !== "") {
85+
items.splice(11, 0, `\`\`\`${parsedBody.previousCourses}\`\`\``);
86+
}
87+
88+
const text = items.join("\n");
6789

6890
// Send the payload to the configured Slack webhook URL
6991
await axios.post(

0 commit comments

Comments
 (0)