From 144f8a0595c1677573cfb2db2fea4558039a521a Mon Sep 17 00:00:00 2001 From: "ashutosh.nehete" Date: Wed, 7 May 2025 16:22:09 +0530 Subject: [PATCH] Added validation to the Completed Work field to prevent negative values. --- src/components/Project/Infrastructure/EditActivityModal.jsx | 3 +-- src/components/Project/Infrastructure/TaskModel.jsx | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/Project/Infrastructure/EditActivityModal.jsx b/src/components/Project/Infrastructure/EditActivityModal.jsx index 884e7aba..44d7b87e 100644 --- a/src/components/Project/Infrastructure/EditActivityModal.jsx +++ b/src/components/Project/Infrastructure/EditActivityModal.jsx @@ -19,7 +19,7 @@ const taskSchema = z .object({ activityID: z.string().min(1, "Activity is required"), plannedWork: z.number().min(1, "Planned Work must be greater than 0"), - completedWork: z.number().optional(), + completedWork: z.number().min(0, "Completed Work must be greater than 0"), }) .refine( (data) => @@ -84,7 +84,6 @@ const EditActivityModal = ({ floorId: floor?.id, workAreaId: workArea?.id, }; - console.log(finalData); ProjectRepository.manageProjectTasks([finalData]) .then((response) => { diff --git a/src/components/Project/Infrastructure/TaskModel.jsx b/src/components/Project/Infrastructure/TaskModel.jsx index c38b5669..810b38ea 100644 --- a/src/components/Project/Infrastructure/TaskModel.jsx +++ b/src/components/Project/Infrastructure/TaskModel.jsx @@ -10,7 +10,7 @@ const taskSchema = z.object({ workAreaId: z.string().min(1, "Work Area is required"), activityID: z.string().min(1, "Activity is required"), plannedWork: z.number().min(1, "Planned Work must be greater than 0"), - completedWork: z.number().optional(), + completedWork: z.number().min(0, "Completed Work must be greater than 0"), }); const defaultModel = {