From 679ae95b8c51da54061e3b77f50db5c1f0076526 Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Mon, 17 Nov 2025 15:21:31 +0530 Subject: [PATCH] Removing project selection at Job Creation. --- src/components/ServiceProject/ManageJob.jsx | 41 +++++++++------------ 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/components/ServiceProject/ManageJob.jsx b/src/components/ServiceProject/ManageJob.jsx index 8f151da3..d769470b 100644 --- a/src/components/ServiceProject/ManageJob.jsx +++ b/src/components/ServiceProject/ManageJob.jsx @@ -20,8 +20,11 @@ import { AppFormProvider, useAppForm, } from "../../hooks/appHooks/useAppForm"; +import { useParams } from "react-router-dom"; const ManageJob = ({ Job }) => { + const { projectId } = useParams(); + const methods = useAppForm({ resolver: zodResolver(jobSchema), defaultValues: defaultJobValue, @@ -54,7 +57,6 @@ const ManageJob = ({ Job }) => { isError: isJobError, error: jobError, } = useServiceProjectJobDetails(Job); - // const {} = useSer const { mutate: CreateJob, isPending } = useCreateServiceProjectJob(() => { reset(); @@ -68,22 +70,33 @@ const ManageJob = ({ Job }) => { formData.startDate = localToUtc(formData.startDate); formData.dueDate = localToUtc(formData.dueDate); + formData.projectId = projectId; CreateJob(formData); }; useEffect(() => { + if (!JobData && !Job) { + reset({ + ...defaultJobValue, + projectId: projectId, + }); + return; + } + if (!JobData || !Job) return; + const assignedEmployees = (JobData.assignees || []).map((e) => e.id); + reset({ title: JobData.title ?? "", description: JobData.description ?? "", - projectId: JobData.project.id ?? "", + projectId: JobData.project?.id ?? projectId, assignees: assignedEmployees, startDate: JobData.startDate ?? null, dueDate: JobData.dueDate ?? null, tags: JobData.tags ?? [], }); - }, [JobData]); + }, [JobData, Job, projectId]); return (
@@ -97,25 +110,7 @@ const ManageJob = ({ Job }) => { className="form-control form-control" />
-
- ( - - )} - /> -
+
{ minDate={watch("startDate")} name="dueDate" className="w-full" - size="md" + size="md" />