diff --git a/cv-project/src/App.jsx b/cv-project/src/App.jsx index 3a2a6ad..72484ca 100644 --- a/cv-project/src/App.jsx +++ b/cv-project/src/App.jsx @@ -1,15 +1,42 @@ -import GeneralInfo from "./components/generalInfo"; -import EducationInfo from "./components/educationInfo"; -import Experience from "./components/experience"; +import GeneralInfoForm from "./components/generalInfoForm"; +import GeneralInfoDisplay from "./components/generalInfoDisplay"; +import EducationInfoDisplay from "./components/educationInfoDisplay"; +import EducationInfoForm from "./components/educationInfoForm"; +import ExperienceForm from "./components/experienceForm"; import "./App.css"; +import { useState } from "react"; function App() { + const [basicInfo, setBasicInfo] = useState({ + firstName: "", + lastName: "", + phone: "", + email: "", + }); + const [educationInfo, setEducationInfo] = useState([]); + const [editEducation, setEditEducation] = useState(null); + return ( - <> - - - - +
+
+ + + +
+
+ + +
+
); } diff --git a/cv-project/src/components/educationInfoDisplay.jsx b/cv-project/src/components/educationInfoDisplay.jsx new file mode 100644 index 0000000..f64abc9 --- /dev/null +++ b/cv-project/src/components/educationInfoDisplay.jsx @@ -0,0 +1,54 @@ +export default function EducationInfoDisplay(props) { + return ( +
+ {props.educationInfo.length <= 0 ? ( + <> +

Add your Education info

+ + ) : ( + + )} +
+ ); +} + +function EducationDisplay(props) { + return ( +
+ {props.educationInfo.map((item) => { + return ( +
+

School: {item.schoolName}

+

+ Graduation Date: {item.graduationDate + " "} + Field of Study: {item.fieldOfStudy} + + +

+
+ ); + })} +
+ ); +} + +function deleteEducationItem(educationInfo, item, setEducationInfo) { + const filteredSchools = educationInfo.filter( + (school) => school.schoolName !== item, + ); + setEducationInfo(filteredSchools); +} diff --git a/cv-project/src/components/educationInfo.jsx b/cv-project/src/components/educationInfoForm.jsx similarity index 59% rename from cv-project/src/components/educationInfo.jsx rename to cv-project/src/components/educationInfoForm.jsx index 78bfd3a..c94fdfc 100644 --- a/cv-project/src/components/educationInfo.jsx +++ b/cv-project/src/components/educationInfoForm.jsx @@ -1,29 +1,12 @@ import { useState, useEffect } from "react"; -export default function EducationInfo() { - const [schools, setSchools] = useState([]); +export default function EducationInfoForm(props) { + // const [schools, setSchools] = useState([]); const [educationItemActive, setEducationItemActive] = useState(false); - const [editSchool, setEditSchool] = useState(null); - - const mainDivStyle = { - display: "flex", - justifyContent: "space-between", - flexDirection: "row-reverse", - }; + // const [editSchool, setEditSchool] = useState(null); return ( -
- {schools.length <= 0 ? ( - <> -

Add your Education info

- - ) : ( - - )} +
); } -function EducationDisplay(props) { - return ( -
- {props.schools.map((item) => { - return ( -
-

School: {item.schoolName}

-

- Graduation Date: {item.graduationDate + " "} - Field of Study: {item.fieldOfStudy} - - -

-
- ); - })} -
- ); -} - -function EducationForm({ isActive, schools, setSchools, editSchool }) { +function EducationForm({ + isActive, + educationInfo, + setEducationInfo, + editSchool, +}) { const [graduationDate, setGraduationDate] = useState(""); const [schoolName, setSchoolName] = useState(""); const [fieldOfStudy, setFieldOfStudy] = useState(""); @@ -92,7 +50,9 @@ function EducationForm({ isActive, schools, setSchools, editSchool }) { }, [editSchool]); let schoolId = editSchool - ? schools.findIndex((school) => school.schoolName === editSchool.schoolName) + ? educationInfo.findIndex( + (school) => school.schoolName === editSchool.schoolName, + ) : null; const contactFormStyle = { @@ -128,17 +88,17 @@ function EducationForm({ isActive, schools, setSchools, editSchool }) { type="submit" onClick={(e) => { e.preventDefault(); - const updatedSchools = [...schools]; + const updatedSchools = [...educationInfo]; if (schoolId !== -1 && schoolId !== null) { updatedSchools[schoolId] = { schoolName: schoolName, graduationDate: graduationDate, fieldOfStudy: fieldOfStudy, }; - setSchools(updatedSchools); + setEducationInfo(updatedSchools); } else { - setSchools([ - ...schools, + setEducationInfo([ + ...educationInfo, { schoolName: schoolName, fieldOfStudy: fieldOfStudy, @@ -170,10 +130,3 @@ function EducationForm({ isActive, schools, setSchools, editSchool }) {
); } - -function deleteEducationItem(schools, item, setSchools) { - const filteredSchools = schools.filter( - (school) => school.schoolName !== item, - ); - setSchools(filteredSchools); -} diff --git a/cv-project/src/components/experience.jsx b/cv-project/src/components/experienceForm.jsx similarity index 98% rename from cv-project/src/components/experience.jsx rename to cv-project/src/components/experienceForm.jsx index 0ef96b6..854c292 100644 --- a/cv-project/src/components/experience.jsx +++ b/cv-project/src/components/experienceForm.jsx @@ -1,6 +1,6 @@ import { useState } from "react"; -export default function Experience() { +export default function ExperienceForm() { const [jobs, setJobs] = useState([]); const [showJobForm, setShowJobForm] = useState(false); diff --git a/cv-project/src/components/generalInfoDisplay.jsx b/cv-project/src/components/generalInfoDisplay.jsx new file mode 100644 index 0000000..5b4621d --- /dev/null +++ b/cv-project/src/components/generalInfoDisplay.jsx @@ -0,0 +1,18 @@ +export default function GeneralInfoDisplay(props) { + const basicInfo = props.basicInfo; + return ( + <> + { + basicInfo ? + ( +
+

{basicInfo.firstName + " " + basicInfo.lastName}

+

{basicInfo.email}

+

{basicInfo.phone}

+
+ ) : null + } + + + ) +} diff --git a/cv-project/src/components/generalInfo.jsx b/cv-project/src/components/generalInfoForm.jsx similarity index 59% rename from cv-project/src/components/generalInfo.jsx rename to cv-project/src/components/generalInfoForm.jsx index ef93169..cfafd7e 100644 --- a/cv-project/src/components/generalInfo.jsx +++ b/cv-project/src/components/generalInfoForm.jsx @@ -1,6 +1,6 @@ import { useState } from "react"; -export default function GeneralInfo() { +export default function GeneralInfoForm(props) { const [firstName, setFirstName] = useState(""); const [lastName, setLastName] = useState(""); const [phone, setPhone] = useState(""); @@ -26,35 +26,43 @@ export default function GeneralInfo() { type="text" placeholder="First Name" value={firstName} - onChange={(e) => setFirstName(e.target.value)} + onChange={(e) => { + setFirstName(e.target.value) + props.setBasicInfo({ ...props.basicInfo, firstName: e.target.value }) + } + } /> setLastName(e.target.value)} - /> + onChange={(e) => { + setLastName(e.target.value) + props.setBasicInfo({ ...props.basicInfo, lastName: e.target.value }) + }} /> setEmail(e.target.value)} + onChange={(e) => { + setEmail(e.target.value) + props.setBasicInfo({ ...props.basicInfo, email: e.target.value }) + } + } /> setPhone(e.target.value)} + onChange={(e) => { + setPhone(e.target.value) + props.setBasicInfo({ ...props.basicInfo, phone: e.target.value }) + }} /> -
-

{firstName + " " + lastName}

-

{email}

-

{phone}

-
); }