added refresh Manage Job form whenever closing after editing and creating job
This commit is contained in:
parent
c311324bad
commit
d342550b0f
@ -34,6 +34,7 @@ const Jobs = () => {
|
|||||||
setSelectedJob,
|
setSelectedJob,
|
||||||
setSelectedProject,
|
setSelectedProject,
|
||||||
setManageJob,
|
setManageJob,
|
||||||
|
manageJob,
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@ -20,8 +20,10 @@ import {
|
|||||||
AppFormProvider,
|
AppFormProvider,
|
||||||
useAppForm,
|
useAppForm,
|
||||||
} from "../../hooks/appHooks/useAppForm";
|
} from "../../hooks/appHooks/useAppForm";
|
||||||
|
import { useServiceProjectJobContext } from "./Jobs";
|
||||||
|
|
||||||
const ManageJob = ({ Job }) => {
|
const ManageJob = ({ Job }) => {
|
||||||
|
const { manageJob, setManageJob } = useServiceProjectJobContext();
|
||||||
const methods = useAppForm({
|
const methods = useAppForm({
|
||||||
resolver: zodResolver(jobSchema),
|
resolver: zodResolver(jobSchema),
|
||||||
defaultValues: defaultJobValue,
|
defaultValues: defaultJobValue,
|
||||||
@ -53,8 +55,7 @@ const ManageJob = ({ Job }) => {
|
|||||||
isLoading: isJobLoading,
|
isLoading: isJobLoading,
|
||||||
isError: isJobError,
|
isError: isJobError,
|
||||||
error: jobError,
|
error: jobError,
|
||||||
} = useServiceProjectJobDetails(Job);
|
} = useServiceProjectJobDetails(manageJob.jobId);
|
||||||
// const {} = useSer
|
|
||||||
|
|
||||||
const { mutate: CreateJob, isPending } = useCreateServiceProjectJob(() => {
|
const { mutate: CreateJob, isPending } = useCreateServiceProjectJob(() => {
|
||||||
reset();
|
reset();
|
||||||
@ -72,7 +73,8 @@ const ManageJob = ({ Job }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!JobData || !Job) return;
|
if (manageJob.jobId && JobData) {
|
||||||
|
console.log("freshed data");
|
||||||
const assignedEmployees = (JobData.assignees || []).map((e) => e.id);
|
const assignedEmployees = (JobData.assignees || []).map((e) => e.id);
|
||||||
reset({
|
reset({
|
||||||
title: JobData.title ?? "",
|
title: JobData.title ?? "",
|
||||||
@ -83,7 +85,11 @@ const ManageJob = ({ Job }) => {
|
|||||||
dueDate: JobData.dueDate ?? null,
|
dueDate: JobData.dueDate ?? null,
|
||||||
tags: JobData.tags ?? [],
|
tags: JobData.tags ?? [],
|
||||||
});
|
});
|
||||||
}, [JobData]);
|
}
|
||||||
|
if (!manageJob.jobId) {
|
||||||
|
reset(defaultJobValue);
|
||||||
|
}
|
||||||
|
}, [JobData, manageJob]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user