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 add contactinfo

Khuram Niaze6d7dda77d20
diff --git a/src/components/admin/AddCompany.tsx b/src/components/admin/AddCompany.tsx
index 22dbcb4..c6e893c 100644
--- a/src/components/admin/AddCompany.tsx
+++ b/src/components/admin/AddCompany.tsx
@@ -53,7 +53,6 @@ function AddCompany({
const { reset, formState } = form;
useEffect(() => {
- console.log("use effect");
if (editCompany) {
reset(
{
diff --git a/src/components/profile/AddContactInfo.tsx b/src/components/profile/AddContactInfo.tsx
index e38d1c0..71baaf0 100644
--- a/src/components/profile/AddContactInfo.tsx
+++ b/src/components/profile/AddContactInfo.tsx
@@ -3,7 +3,6 @@ import { Loader } from "lucide-react";
import { Button } from "../ui/button";
import {
Dialog,
- DialogClose,
DialogContent,
DialogFooter,
DialogHeader,
@@ -53,23 +52,27 @@ function AddContactInfo({
},
});
- const { setValue, reset, formState, clearErrors } = form;
+ const { reset, formState } = form;
useEffect(() => {
if (contactInfoToEdit) {
- clearErrors();
- setValue("id", contactInfoToEdit.id);
- setValue("resumeId", contactInfoToEdit.resumeId);
- setValue("firstName", contactInfoToEdit.firstName);
- setValue("lastName", contactInfoToEdit.lastName);
- setValue("headline", contactInfoToEdit.headline);
- setValue("email", contactInfoToEdit.email);
- setValue("phone", contactInfoToEdit.phone);
- setValue("address", contactInfoToEdit.address);
+ reset(
+ {
+ id: contactInfoToEdit.id,
+ resumeId: contactInfoToEdit.resumeId,
+ firstName: contactInfoToEdit.firstName,
+ lastName: contactInfoToEdit.lastName,
+ headline: contactInfoToEdit.headline,
+ email: contactInfoToEdit.email,
+ phone: contactInfoToEdit.phone,
+ address: contactInfoToEdit.address,
+ },
+ { keepDefaultValues: true }
+ );
} else {
reset();
}
- }, [contactInfoToEdit, setValue, clearErrors, reset, dialogOpen]);
+ }, [contactInfoToEdit, reset]);
const onSubmit = (data: z.infer<typeof AddContactInfoFormSchema>) => {
startTransition(async () => {
@@ -211,15 +214,16 @@ function AddContactInfo({
<DialogFooter
// className="md:col-span
>
- <DialogClose>
+ <div>
<Button
type="reset"
variant="outline"
className="mt-2 md:mt-0 w-full"
+ onClick={() => setDialogOpen(false)}
>
Cancel
</Button>
- </DialogClose>
+ </div>
<Button type="submit" disabled={!formState.isDirty}>
Save
{isPending && <Loader className="h-4 w-4 shrink-0 spinner" />}