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