Skip to content

Commit

Permalink
Add question for concurrent courses or programs
Browse files Browse the repository at this point in the history
  • Loading branch information
jonulak committed Nov 30, 2024
1 parent 3ba4e53 commit 8047b39
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/components/forms/apply-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ interface IFormValues {
yearSeparated: string;
hasAttendedPreviousCourse: boolean;
previousCourses: string;
willAttendAnotherCourse: boolean;
otherCourses: string;
linkedInAccountName: string;
githubAccountName: string;
preworkLink: string;
Expand All @@ -43,6 +45,8 @@ const ApplyForm = () => {
} = useForm<IFormValues>();

const watchHasAttendedPreviousCourses = watch("hasAttendedPreviousCourse", false);
const watchWillAttendAnotherCourse = watch("willAttendAnotherCourse", false);


const onSubmit: SubmitHandler<IFormValues> = async (data) => {
try {
Expand Down Expand Up @@ -241,7 +245,7 @@ const ApplyForm = () => {
animate={{ opacity: 1, scale: 1 }}
>
<label htmlFor="previousCourses" className="tw-text-heading tw-text-md">
Previous Courses *
List previous courses *
</label>
<TextArea
id="previousCourses"
Expand All @@ -256,6 +260,37 @@ const ApplyForm = () => {
/>
</motion.div>
)}
<motion.div layout>
<Checkbox
label="Will you be attending any other courses or programs concurrently with Vets Who Code?"
id="willAttendAnotherCourse"
{...register("willAttendAnotherCourse")}
/>
<br />
</motion.div>
{watchWillAttendAnotherCourse && (
<motion.div
layout
className="tw-mb-7.5"
initial={{ opacity: 0, scale: 0.4 }}
animate={{ opacity: 1, scale: 1 }}
>
<label htmlFor="otherCourses" className="tw-text-heading tw-text-md">
List concurrent courses/programs *
</label>
<TextArea
id="otherCourses"
placeholder="Fundamentals of Spouse Stealing"
bg="light"
feedbackText={errors?.otherCourses?.message}
state={hasKey(errors, "otherCourses") ? "error" : "success"}
showState={!!hasKey(errors, "otherCourses")}
{...register("otherCourses", {
required: "List concurrent coursework or uncheck the box",
})}
/>
</motion.div>
)}
<motion.div layout className="tw-mb-7.5">
<label htmlFor="linkedInAccountName" className="tw-text-heading tw-text-md">
LinkedIn Account Name *
Expand Down
10 changes: 10 additions & 0 deletions src/pages/api/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ interface ParsedBody {
yearSeparated?: string;
hasAttendedPreviousCourse?: boolean;
previousCourses?: string;
willAttendAnotherCourse?: boolean;
otherCourses?: string;
linkedInAccountName?: string;
githubAccountName?: string;
preworkLink?: string;
Expand All @@ -37,6 +39,7 @@ export default async function handler(req: Request, res: Response) {
"yearJoined",
"yearSeparated",
"hasAttendedPreviousCourse",
"willAttendAnotherCourse",
"linkedInAccountName",
"githubAccountName",
"preworkLink",
Expand Down Expand Up @@ -65,12 +68,19 @@ export default async function handler(req: Request, res: Response) {
`Has attended previous bootcamp/programs: \`${
parsedBody.hasAttendedPreviousCourse ? "Yes" : "No"
}\``,
`Will do other courses/programs concurrently: \`${
parsedBody.willAttendAnotherCourse ? "Yes" : "No"
}\``,
`LinkedIn Account Name: \`${parsedBody.linkedInAccountName ?? ""}\``,
`GitHub Account Name: \`${parsedBody.githubAccountName ?? ""}\``,
`Prework Link: \`${parsedBody.preworkLink ?? ""}\``,
`Prework Repository: \`${parsedBody.preworkRepo ?? ""}\``,
];

if (parsedBody.willAttendAnotherCourse && parsedBody.otherCourses !== "") {
items.splice(12, 0, `\`\`\`${parsedBody.otherCourses}\`\`\``);
}

if (parsedBody.hasAttendedPreviousCourse && parsedBody.previousCourses !== "") {
items.splice(11, 0, `\`\`\`${parsedBody.previousCourses}\`\`\``);
}
Expand Down

0 comments on commit 8047b39

Please sign in to comment.