Added Services Column in Edit activity modal
This commit is contained in:
parent
271d148100
commit
6854396c8c
@ -32,9 +32,8 @@ const EditActivityModal = ({
|
|||||||
building,
|
building,
|
||||||
floor,
|
floor,
|
||||||
onClose,
|
onClose,
|
||||||
} ) =>
|
}) => {
|
||||||
{
|
|
||||||
|
|
||||||
const { activities, loading: loadingActivities } = useActivitiesMaster();
|
const { activities, loading: loadingActivities } = useActivitiesMaster();
|
||||||
const { categories, loading: loadingCategories } = useWorkCategoriesMaster();
|
const { categories, loading: loadingCategories } = useWorkCategoriesMaster();
|
||||||
const [selectedActivity, setSelectedActivity] = useState(null);
|
const [selectedActivity, setSelectedActivity] = useState(null);
|
||||||
@ -57,13 +56,12 @@ const EditActivityModal = ({
|
|||||||
comment: "",
|
comment: "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { mutate: UpdateTask, isPending } = useManageTask({
|
const { mutate: UpdateTask, isPending } = useManageTask({
|
||||||
onSuccessCallback: (response) =>
|
onSuccessCallback: (response) => {
|
||||||
{
|
showToast(response?.message, "success")
|
||||||
showToast( response?.message, "success" )
|
onClose()
|
||||||
onClose()
|
}
|
||||||
}
|
});
|
||||||
} );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -82,34 +80,33 @@ const { mutate: UpdateTask, isPending } = useManageTask({
|
|||||||
[categories]
|
[categories]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!workItem) return;
|
if (!workItem) return;
|
||||||
console.log(workItem)
|
console.log(workItem)
|
||||||
reset({
|
reset({
|
||||||
activityID: String(
|
activityID: String(
|
||||||
workItem?.workItem?.activityId || workItem?.activityMaster?.id
|
workItem?.workItem?.activityId || workItem?.activityMaster?.id
|
||||||
),
|
),
|
||||||
workCategoryId: String(
|
workCategoryId: String(
|
||||||
workItem?.workItem?.workCategoryId || workItem?.workCategoryMaster?.id
|
workItem?.workItem?.workCategoryId || workItem?.workCategoryMaster?.id
|
||||||
),
|
),
|
||||||
plannedWork:
|
plannedWork:
|
||||||
workItem?.workItem?.plannedWork || workItem?.plannedWork || 0,
|
workItem?.workItem?.plannedWork || workItem?.plannedWork || 0,
|
||||||
completedWork:
|
completedWork:
|
||||||
workItem?.workItem?.completedWork || workItem?.completedWork || 0,
|
workItem?.workItem?.completedWork || workItem?.completedWork || 0,
|
||||||
comment: workItem?.workItem?.description || workItem?.description || "",
|
comment: workItem?.workItem?.description || workItem?.description || "",
|
||||||
});
|
});
|
||||||
}, [workItem?.id,selectedActivity]);
|
}, [workItem?.id, selectedActivity]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const selected = activities?.find((a) => a.id === activityID);
|
const selected = activities?.find((a) => a.id === activityID);
|
||||||
setSelectedActivity( selected || null );
|
setSelectedActivity(selected || null);
|
||||||
}, [activityID, activities]);
|
}, [activityID, activities]);
|
||||||
|
|
||||||
const onSubmitForm = (data) =>
|
const onSubmitForm = (data) => {
|
||||||
{
|
const payload = {
|
||||||
const payload = {
|
|
||||||
...data,
|
...data,
|
||||||
id: workItem?.workItem?.id ?? workItem?.id,
|
id: workItem?.workItem?.id ?? workItem?.id,
|
||||||
buildingID: building?.id,
|
buildingID: building?.id,
|
||||||
@ -125,9 +122,9 @@ useEffect(() => {
|
|||||||
buildingId: building?.id,
|
buildingId: building?.id,
|
||||||
floorId: floor?.id,
|
floorId: floor?.id,
|
||||||
workAreaId: workArea?.id,
|
workAreaId: workArea?.id,
|
||||||
previousCompletedWork:completedTask
|
previousCompletedWork: completedTask
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<form className="row g-2 p-2 p-md-1" onSubmit={handleSubmit(onSubmitForm)}>
|
<form className="row g-2 p-2 p-md-1" onSubmit={handleSubmit(onSubmitForm)}>
|
||||||
<div className="text-center mb-1">
|
<div className="text-center mb-1">
|
||||||
@ -162,14 +159,26 @@ useEffect(() => {
|
|||||||
disabled
|
disabled
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="col-12 text-start">
|
||||||
|
<label className="form-label">Select Service</label>
|
||||||
|
<input
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
value={
|
||||||
|
workItem?.activityMaster?.activityGroupMaster?.service?.name || ""
|
||||||
|
}
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div className="col-12 text-start">
|
<div className="col-12 text-start">
|
||||||
<label className="form-label">Select Activity</label>
|
<label className="form-label">Select Activity</label>
|
||||||
<select
|
<select
|
||||||
{...register("activityID")}
|
{...register("activityID")}
|
||||||
className="form-select form-select-sm"
|
className="form-select form-select-sm"
|
||||||
|
disabled
|
||||||
>
|
>
|
||||||
<option disabled>Select Activity</option>
|
<option >Select Activity</option>
|
||||||
{loadingActivities ? (
|
{loadingActivities ? (
|
||||||
<option>Loading...</option>
|
<option>Loading...</option>
|
||||||
) : (
|
) : (
|
||||||
@ -264,7 +273,7 @@ useEffect(() => {
|
|||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
>
|
>
|
||||||
{isPending ? "Please Wait..." : "Edit Task"}
|
{isPending ? "Please Wait..." : "Edit Task"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
|
@ -17,6 +17,7 @@ const taskSchema = z.object({
|
|||||||
buildingID: z.string().min(1, "Building is required"),
|
buildingID: z.string().min(1, "Building is required"),
|
||||||
floorId: z.string().min(1, "Floor is required"),
|
floorId: z.string().min(1, "Floor is required"),
|
||||||
workAreaId: z.string().min(1, "Work Area is required"),
|
workAreaId: z.string().min(1, "Work Area is required"),
|
||||||
|
serviceId: z.string().min(1, "Service is required"),
|
||||||
activityGroupId: z.string().min(1, "Activity Group is required"),
|
activityGroupId: z.string().min(1, "Activity Group is required"),
|
||||||
activityID: z.string().min(1, "Activity is required"),
|
activityID: z.string().min(1, "Activity is required"),
|
||||||
workCategoryId: z.string().min(1, "Work Category is required"),
|
workCategoryId: z.string().min(1, "Work Category is required"),
|
||||||
@ -30,6 +31,7 @@ const defaultModel = {
|
|||||||
buildingID: "",
|
buildingID: "",
|
||||||
floorId: "",
|
floorId: "",
|
||||||
workAreaId: "",
|
workAreaId: "",
|
||||||
|
serviceId: "",
|
||||||
activityGroupId: "",
|
activityGroupId: "",
|
||||||
activityID: "",
|
activityID: "",
|
||||||
workCategoryId: "",
|
workCategoryId: "",
|
||||||
@ -219,8 +221,13 @@ const TaskModel = ({ project, onSubmit, onClose }) => {
|
|||||||
<Label className="form-label" required>Select Service</Label>
|
<Label className="form-label" required>Select Service</Label>
|
||||||
<select
|
<select
|
||||||
className="form-select form-select-sm"
|
className="form-select form-select-sm"
|
||||||
|
{...register("serviceId")}
|
||||||
value={selectedService}
|
value={selectedService}
|
||||||
onChange={handleServiceChange}
|
// onChange={handleServiceChange}
|
||||||
|
onChange={(e) => {
|
||||||
|
handleServiceChange(e);
|
||||||
|
setValue("serviceId", e.target.value);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<option value="">Select Service</option>
|
<option value="">Select Service</option>
|
||||||
{servicesLoading && <option>Loading...</option>}
|
{servicesLoading && <option>Loading...</option>}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user