Added new field comment
This commit is contained in:
parent
60d232f5be
commit
edcc4438a2
@ -20,7 +20,8 @@ const taskSchema = z
|
|||||||
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"),
|
||||||
plannedWork: z.number().min(1, "Planned Work must be greater than 0"),
|
plannedWork: z.number().min(1, "Planned Work must be greater than 0"),
|
||||||
completedWork: z.number().min(0, "Completed Work must be greater than 0"),
|
completedWork: z.number().min( 0, "Completed Work must be greater than 0" ),
|
||||||
|
comment:z.string()
|
||||||
})
|
})
|
||||||
.refine(
|
.refine(
|
||||||
(data) =>
|
(data) =>
|
||||||
@ -47,6 +48,7 @@ const EditActivityModal = ({
|
|||||||
workCategoryId: 0,
|
workCategoryId: 0,
|
||||||
plannedWork: 0,
|
plannedWork: 0,
|
||||||
completedWork: 0,
|
completedWork: 0,
|
||||||
|
comment:""
|
||||||
};
|
};
|
||||||
|
|
||||||
const { projects_Details, refetch } = useProjectDetails(selectedProject);
|
const { projects_Details, refetch } = useProjectDetails(selectedProject);
|
||||||
@ -185,6 +187,8 @@ const EditActivityModal = ({
|
|||||||
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 || ""
|
||||||
});
|
});
|
||||||
return () => reset();
|
return () => reset();
|
||||||
}, [activities, workItem]);
|
}, [activities, workItem]);
|
||||||
@ -384,6 +388,27 @@ const EditActivityModal = ({
|
|||||||
</div>
|
</div>
|
||||||
{/* )} */}
|
{/* )} */}
|
||||||
|
|
||||||
|
|
||||||
|
<div className="col-12">
|
||||||
|
<label
|
||||||
|
className="form-text fs-7 m-1 text-lg text-dark"
|
||||||
|
htmlFor="descriptionTextarea"
|
||||||
|
>
|
||||||
|
Comment
|
||||||
|
</label>
|
||||||
|
<textarea
|
||||||
|
{...register("comment")}
|
||||||
|
className="form-control"
|
||||||
|
id="descriptionTextarea"
|
||||||
|
rows="2"
|
||||||
|
/>
|
||||||
|
{errors.comment && (
|
||||||
|
<div className="danger-text">
|
||||||
|
{errors.comment.message}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="col-12 text-center">
|
<div className="col-12 text-center">
|
||||||
<button type="submit" className="btn btn-sm btn-primary me-3" disabled={activities.length === 0 || isSubmitting}>
|
<button type="submit" className="btn btn-sm btn-primary me-3" disabled={activities.length === 0 || isSubmitting}>
|
||||||
{isSubmitting ? "Please Wait.." : "Edit Task"}
|
{isSubmitting ? "Please Wait.." : "Edit Task"}
|
||||||
|
|||||||
@ -14,7 +14,8 @@ const taskSchema = z.object({
|
|||||||
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"),
|
||||||
plannedWork: z.number().min(1, "Planned Work must be greater than 0"),
|
plannedWork: z.number().min(1, "Planned Work must be greater than 0"),
|
||||||
completedWork: z.number().min(0, "Completed Work must be greater than 0"),
|
completedWork: z.number().min( 0, "Completed Work must be greater than 0" ),
|
||||||
|
comment:z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const defaultModel = {
|
const defaultModel = {
|
||||||
@ -26,6 +27,7 @@ const defaultModel = {
|
|||||||
workCategoryId: "",
|
workCategoryId: "",
|
||||||
plannedWork: 0,
|
plannedWork: 0,
|
||||||
completedWork: 0,
|
completedWork: 0,
|
||||||
|
comment:""
|
||||||
};
|
};
|
||||||
|
|
||||||
const TaskModel = ({
|
const TaskModel = ({
|
||||||
@ -124,7 +126,7 @@ const TaskModel = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onSubmitForm = async (data) => {
|
const onSubmitForm = async (data) => {
|
||||||
console.log(data);
|
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
await onSubmit(data);
|
await onSubmit(data);
|
||||||
setValue("plannedWork", 0);
|
setValue("plannedWork", 0);
|
||||||
@ -136,7 +138,7 @@ const TaskModel = ({
|
|||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
setFormData(defaultModel);
|
setFormData(defaultModel);
|
||||||
setSelectedBuilding(null); // not "0"
|
setSelectedBuilding(null);
|
||||||
setSelectedFloor(null);
|
setSelectedFloor(null);
|
||||||
setSelectedWorkArea(null);
|
setSelectedWorkArea(null);
|
||||||
setSelectedActivity(null);
|
setSelectedActivity(null);
|
||||||
@ -386,7 +388,6 @@ const TaskModel = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Unit */}
|
|
||||||
{selectedActivity && selectedCategory && (
|
{selectedActivity && selectedCategory && (
|
||||||
<div className="col-2 col-md-2">
|
<div className="col-2 col-md-2">
|
||||||
<label className="form-label" htmlFor="unit">
|
<label className="form-label" htmlFor="unit">
|
||||||
@ -400,7 +401,27 @@ const TaskModel = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{selectedActivity && selectedCategory && (
|
||||||
|
<div className="col-12">
|
||||||
|
<label
|
||||||
|
className="form-text fs-7 m-1 text-lg text-dark"
|
||||||
|
htmlFor="descriptionTextarea"
|
||||||
|
>
|
||||||
|
Comment
|
||||||
|
</label>
|
||||||
|
<textarea
|
||||||
|
{...register("comment")}
|
||||||
|
className="form-control"
|
||||||
|
id="descriptionTextarea"
|
||||||
|
rows="2"
|
||||||
|
/>
|
||||||
|
{errors.comment && (
|
||||||
|
<div className="danger-text">
|
||||||
|
{errors.comment.message}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="col-12 text-center">
|
<div className="col-12 text-center">
|
||||||
<button type="submit" className="btn btn-sm btn-primary me-3">
|
<button type="submit" className="btn btn-sm btn-primary me-3">
|
||||||
{isSubmitting ? "Please Wait.." : "Add Task"}
|
{isSubmitting ? "Please Wait.." : "Add Task"}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user