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.

Refactor: AddResumeSummary and addEducation, minor fix

Khuram Niaz066f6905c2a0
diff --git a/src/components/profile/AddEducation.tsx b/src/components/profile/AddEducation.tsx
index ad81d42..24b4435 100644
--- a/src/components/profile/AddEducation.tsx
+++ b/src/components/profile/AddEducation.tsx
@@ -67,34 +67,40 @@ function AddEducation({
},
});
- const { setValue, watch, reset, formState, resetField, clearErrors } = form;
+ const { watch, reset, formState, resetField } = form;
const degreeCompletedValue = watch("degreeCompleted");
useEffect(() => {
getLocationData();
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);
+ reset(
+ {
+ id: education?.id,
+ institution: education?.institution,
+ degree: education?.degree,
+ fieldOfStudy: education?.fieldOfStudy,
+ location: education?.location.id,
+ startDate: education?.startDate,
+ endDate: education?.endDate,
+ description: education?.description,
+ degreeCompleted: !!education?.endDate,
+ },
+ { keepDefaultValues: true }
+ );
} else {
- reset();
+ reset(
+ {
+ sectionId,
+ },
+ { keepDefaultValues: true }
+ );
resetEducationToEdit();
}
- setValue("sectionId", sectionId);
}, [
getLocationData,
educationToEdit,
- clearErrors,
- setValue,
sectionId,
reset,
resetEducationToEdit,
diff --git a/src/components/profile/AddResumeSummary.tsx b/src/components/profile/AddResumeSummary.tsx
index cd71b20..b3d3d3d 100644
--- a/src/components/profile/AddResumeSummary.tsx
+++ b/src/components/profile/AddResumeSummary.tsx
@@ -53,19 +53,23 @@ function AddResumeSummary({
},
});
- const { setValue, reset, formState, clearErrors } = form;
+ const { reset, formState } = form;
useEffect(() => {
if (summaryToEdit) {
- clearErrors();
- setValue("id", summaryToEdit.id);
- setValue("sectionTitle", summaryToEdit.sectionTitle);
- setValue("sectionType", summaryToEdit.sectionType);
- setValue("content", summaryToEdit.summary?.content!);
- } else {
- reset();
+ reset(
+ {
+ id: summaryToEdit.id,
+ sectionTitle: summaryToEdit.sectionTitle,
+ sectionType: summaryToEdit.sectionType,
+ content: summaryToEdit.summary?.content!,
+ },
+ {
+ keepDefaultValues: true,
+ }
+ );
}
- }, [summaryToEdit, setValue, clearErrors, reset, dialogOpen]);
+ }, [summaryToEdit, reset]);
const onSubmit = (data: z.infer<typeof AddSummarySectionFormSchema>) => {
startTransition(async () => {