Skip to content

Commit

Permalink
fix initial 2 work experiences (paths 2,3,4)
Browse files Browse the repository at this point in the history
  • Loading branch information
kathyychenn authored and Miyuki-L committed Nov 21, 2024
1 parent 786f419 commit 830c363
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions frontend/src/components/Step3.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useEffect } from "react";
import { useContext } from "react";
import { Link } from "react-router-dom";

import deleteIcon from "../assets/deleteIcon.svg";
Expand All @@ -16,6 +16,30 @@ export type StepProps = {

function WorkExperienceSection({ pathNumber }: { pathNumber: number }) {
const { formData, setFormData } = useContext(FormContext);
const isRequired = [2, 3, 4].includes(pathNumber);

if (isRequired && formData.WorkExperience.length === 0) {
const newWorkExperience: WorkExperience = {
designExperience: "",
numHours: 0,
superviserName: "",
superviserPhoneNum: "",
superviserEmail: "",
companyName: "",
companyAddress: "",
companyCity: "",
companyState: "",
companyZip: "",
companyCountry: "",
hireDate: "",
lastDateWorked: "",
};

setFormData({
...formData,
WorkExperience: [newWorkExperience],
});
}

const handleInputChange = (
index: number,
Expand Down Expand Up @@ -65,14 +89,6 @@ function WorkExperienceSection({ pathNumber }: { pathNumber: number }) {
}));
};

const isRequired = [2, 3, 4].includes(pathNumber);

useEffect(() => {
if (isRequired && formData.WorkExperience.length === 0) {
addWorkExperience();
}
}, [isRequired, formData.WorkExperience.length]);

return (
<div className={styles.formSection}>
<div className={styles.titleContainer}>
Expand Down

0 comments on commit 830c363

Please sign in to comment.