Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

Edit education section

Khuram Niaze6bca44c0f9e
diff --git a/src/components/profile/AddEducation.tsx b/src/components/profile/AddEducation.tsx
index bfa19bf..3e41fde 100644
--- a/src/components/profile/AddEducation.tsx
+++ b/src/components/profile/AddEducation.tsx
@@ -1,6 +1,6 @@
"use client";
import { AddEducationFormSchema } from "@/models/AddEductionForm.schema";
-import { ResumeSection } from "@/models/profile.model";
+import { Education, ResumeSection } from "@/models/profile.model";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
@@ -74,31 +74,31 @@ function AddEducation({
useEffect(() => {
getLocationData();
- // if (experienceToEdit) {
- // clearErrors();
- // const experience: WorkExperience =
- // experienceToEdit.workExperiences?.pop()!;
- // setValue("id", experience?.id);
- // setValue("title", experience?.jobTitle.id);
- // setValue("company", experience?.Company.id);
- // setValue("location", experience?.location.id);
- // setValue("startDate", experience?.startDate);
- // setValue("endDate", experience?.endDate);
- // setValue("jobDescription", experience?.description);
- // setValue("currentJob", !!!experience?.endDate);
- // } else {
- // reset();
- // resetExperienceToEdit();
- // }
+ if (educationToEdit) {
+ clearErrors();
+ const education: Education = educationToEdit?.educations?.at(0)!;
+ setValue("id", education?.id);
+ setValue("institution", education?.institution);
+ setValue("degree", education?.degree);
+ setValue("fieldOfStudy", education?.fieldOfStudy);
+ setValue("location", education?.location.id);
+ setValue("startDate", education?.startDate);
+ setValue("endDate", education?.endDate);
+ setValue("description", education?.description);
+ setValue("degreeCompleted", !!!education?.endDate);
+ } else {
+ reset();
+ resetEducationToEdit();
+ }
setValue("sectionId", sectionId);
}, [
getLocationData,
- // experienceToEdit,
- // clearErrors,
+ educationToEdit,
+ clearErrors,
setValue,
sectionId,
- // reset,
- // resetExperienceToEdit,
+ reset,
+ resetEducationToEdit,
]);
const onDegreeCompleted = (completed: boolean) => {
@@ -262,7 +262,7 @@ function AddEducation({
<DatePicker
field={field}
presets={false}
- isEnabled={true}
+ isEnabled={degreeCompletedValue!}
captionLayout={true}
/>
<FormMessage />
diff --git a/src/components/profile/AddExperience.tsx b/src/components/profile/AddExperience.tsx
index 56ac4e5..19d76ff 100644
--- a/src/components/profile/AddExperience.tsx
+++ b/src/components/profile/AddExperience.tsx
@@ -85,7 +85,7 @@ function AddExperience({
if (experienceToEdit) {
clearErrors();
const experience: WorkExperience =
- experienceToEdit.workExperiences?.pop()!;
+ experienceToEdit.workExperiences?.at(0)!;
setValue("id", experience?.id);
setValue("title", experience?.jobTitle.id);
setValue("company", experience?.Company.id);
diff --git a/src/components/profile/AddResumeSection.tsx b/src/components/profile/AddResumeSection.tsx
index f40ca3b..0d2ee0e 100644
--- a/src/components/profile/AddResumeSection.tsx
+++ b/src/components/profile/AddResumeSection.tsx
@@ -28,6 +28,7 @@ export interface AddResumeSectionRef {
openContactInfoDialog: (c: ContactInfo) => void;
openSummaryDialog: (s: ResumeSection) => void;
openExperienceDialog: (s: ResumeSection) => void;
+ openEducationDialog: (s: ResumeSection) => void;
}
const AddResumeSection = forwardRef<AddResumeSectionRef, AddResumeSectionProps>(
@@ -43,6 +44,8 @@ const AddResumeSection = forwardRef<AddResumeSectionRef, AddResumeSectionProps>(
);
const [experienceToEdit, setExperienceToEdit] =
useState<ResumeSection | null>(null);
+ const [educationToEdit, setEducationToEdit] =
+ useState<ResumeSection | null>(null);
useImperativeHandle(ref, () => ({
openContactInfoDialog(contactInfo: ContactInfo) {
setContactInfoDialogOpen(true);
@@ -56,6 +59,10 @@ const AddResumeSection = forwardRef<AddResumeSectionRef, AddResumeSectionProps>(
setExperienceDialogOpen(true);
setExperienceToEdit({ ...experienceSection });
},
+ openEducationDialog(educationSection: ResumeSection) {
+ setEducationDialogOpen(true);
+ setEducationToEdit({ ...educationSection });
+ },
}));
const summarySection = resume.ResumeSections?.find(
(section) => section.sectionType === SectionType.SUMMARY
@@ -69,6 +76,10 @@ const AddResumeSection = forwardRef<AddResumeSectionRef, AddResumeSectionProps>(
const resetExperienceToEdit = () => {
setExperienceToEdit(null);
};
+ const resetEducationToEdit = () => {
+ console.log("RESET EDUCTION TO EDIT");
+ setEducationToEdit(null);
+ };
return (
<>
<DropdownMenu>
@@ -136,8 +147,8 @@ const AddResumeSection = forwardRef<AddResumeSectionRef, AddResumeSectionProps>(
sectionId={educationSection?.id}
dialogOpen={educationDialogOpen}
setDialogOpen={setEducationDialogOpen}
- educationToEdit={experienceToEdit!}
- resetEducationToEdit={resetExperienceToEdit}
+ educationToEdit={educationToEdit!}
+ resetEducationToEdit={resetEducationToEdit}
/>
</>
);
diff --git a/src/components/profile/ResumeContainer.tsx b/src/components/profile/ResumeContainer.tsx
index f076d36..3bf5e49 100644
--- a/src/components/profile/ResumeContainer.tsx
+++ b/src/components/profile/ResumeContainer.tsx
@@ -35,13 +35,13 @@ function ResumeContainer({ resume }: { resume: Resume }) {
resumeSectionRef.current?.openExperienceDialog(section);
};
const openEducationDialogForEdit = (educationId: string) => {
- // const section: ResumeSection = {
- // ...experienceSection!,
- // workExperiences: experienceSection?.workExperiences?.filter(
- // (exp) => exp.id === experienceId
- // ),
- // };
- // resumeSectionRef.current?.openExperienceDialog(section);
+ const section: ResumeSection = {
+ ...educationSection!,
+ educations: educationSection?.educations?.filter(
+ (edu) => edu.id === educationId
+ ),
+ };
+ resumeSectionRef.current?.openEducationDialog(section);
};
return (
<>
diff --git a/src/models/AddEductionForm.schema.ts b/src/models/AddEductionForm.schema.ts
index 95f83d1..3645c1e 100644
--- a/src/models/AddEductionForm.schema.ts
+++ b/src/models/AddEductionForm.schema.ts
@@ -30,6 +30,6 @@ export const AddEducationFormSchema = z.object({
}),
description: z.string().optional(),
startDate: z.date(),
- endDate: z.date().optional(),
+ endDate: z.date().nullable().optional(),
degreeCompleted: z.boolean().default(true).optional(),
});
diff --git a/src/models/addExperienceForm.schema.ts b/src/models/addExperienceForm.schema.ts
index 1901dc3..ccc3e19 100644
--- a/src/models/addExperienceForm.schema.ts
+++ b/src/models/addExperienceForm.schema.ts
@@ -31,6 +31,6 @@ export const AddExperienceFormSchema = z.object({
message: "Job description must be at least 10 characters.",
}),
startDate: z.date(),
- endDate: z.date().optional(),
+ endDate: z.date().nullable().optional(),
currentJob: z.boolean().default(false).optional(),
});