From 176535f53f822b95211dc878fc9718327b4fc188 Mon Sep 17 00:00:00 2001 From: "ashutosh.nehete" Date: Tue, 3 Jun 2025 15:55:18 +0530 Subject: [PATCH] Added Column Today's Planned to Project Infrastructure --- src/components/Project/AssignRole.jsx | 93 +++++++++++++------ .../Project/Infrastructure/WorkArea.jsx | 3 + .../Project/Infrastructure/WorkItem.jsx | 24 ++++- 3 files changed, 90 insertions(+), 30 deletions(-) diff --git a/src/components/Project/AssignRole.jsx b/src/components/Project/AssignRole.jsx index 65badfb7..38258bb2 100644 --- a/src/components/Project/AssignRole.jsx +++ b/src/components/Project/AssignRole.jsx @@ -5,12 +5,13 @@ import useMaster from "../../hooks/masterHook/useMaster"; import { useForm, Controller } from "react-hook-form"; import { z } from "zod"; import { zodResolver } from "@hookform/resolvers/zod"; -import { getCachedData } from "../../slices/apiDataManager"; +import { clearCacheKey, getCachedData } from "../../slices/apiDataManager"; import { useEmployeesAllOrByProjectId } from "../../hooks/useEmployees"; import { TasksRepository } from "../../repositories/ProjectRepository"; import showToast from "../../services/toastService"; +import { useProjectDetails } from "../../hooks/useProjects"; -const AssignRoleModel = ({ assignData, onClose }) => { +const AssignRoleModel = ({ assignData, onClose, setAssigned }) => { // Calculate maxPlanned based on assignData const maxPlanned = assignData?.workItem?.workItem?.plannedWork - @@ -50,11 +51,11 @@ const AssignRoleModel = ({ assignData, onClose }) => { // Initialize Bootstrap Popovers on component mount useEffect(() => { // Check if Bootstrap is available globally - if (typeof bootstrap !== 'undefined') { + if (typeof bootstrap !== "undefined") { if (infoRef.current) { new bootstrap.Popover(infoRef.current, { - trigger: 'focus', - placement: 'right', + trigger: "focus", + placement: "right", html: true, content: `
Total Pending tasks of the Activity
`, }); @@ -62,8 +63,8 @@ const AssignRoleModel = ({ assignData, onClose }) => { if (infoRef1.current) { new bootstrap.Popover(infoRef1.current, { - trigger: 'focus', - placement: 'right', + trigger: "focus", + placement: "right", html: true, content: `
Target task for today
`, }); @@ -72,7 +73,6 @@ const AssignRoleModel = ({ assignData, onClose }) => { console.warn("Bootstrap is not available. Popovers might not function."); } }, []); // Empty dependency array ensures this runs once on mount - // Redux state and hooks const selectedProject = useSelector( (store) => store.localVariables.projectId @@ -173,6 +173,8 @@ const AssignRoleModel = ({ assignData, onClose }) => { await TasksRepository.assignTask(formattedData); showToast("Task Successfully Assigned", "success"); // Show success toast reset(); // Reset form fields + clearCacheKey("projectInfo"); + setAssigned(formattedData.plannedTask) onClose(); // Close the modal } catch (error) { console.error("Error assigning task:", error); // Log the full error for debugging @@ -205,7 +207,7 @@ const AssignRoleModel = ({ assignData, onClose }) => {

-

Work Location :

+ Work Location : {[ assignData?.building?.name, assignData?.floor?.floorName, @@ -303,7 +305,9 @@ const AssignRoleModel = ({ assignData, onClose }) => { type="checkbox" id={`employee-${emp?.id}`} value={emp.id} - checked={field.value?.includes(emp.id)} + checked={field.value?.includes( + emp.id + )} onChange={(e) => { handleCheckboxChange(e, emp); }} @@ -311,7 +315,10 @@ const AssignRoleModel = ({ assignData, onClose }) => { )} />
-

+

{emp.firstName} {emp.lastName}

{ }) ) : (
-

No employees found for the selected role.

+

+ No employees found for the selected role. +

)}
@@ -387,23 +396,37 @@ const AssignRoleModel = ({ assignData, onClose }) => { {!loading && errors.selectedEmployees && (
-

{errors.selectedEmployees.message}

{/* Use message from Zod schema */} +

{errors.selectedEmployees.message}

{" "} + {/* Use message from Zod schema */}
)} {/* Pending Task of Activity section */}
-