From 4055a4532cc128eca1c8e2a31635bdd16a499540 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Sun, 4 May 2025 19:03:55 +0530 Subject: [PATCH] updated message when no employees are available ,hide search and "Assign to Project" button while loading, show loader --- src/components/Project/MapUsers.jsx | 61 ++++++++++++++++++----------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/src/components/Project/MapUsers.jsx b/src/components/Project/MapUsers.jsx index 7d31b626..39624dfc 100644 --- a/src/components/Project/MapUsers.jsx +++ b/src/components/Project/MapUsers.jsx @@ -11,10 +11,12 @@ const MapUsers = ({ empJobRoles, onSubmit, allocation, + assignedLoading, + setAssignedLoading, }) => { - const { employeesList, loading:employeeLoading, error } = useAllEmployees(); + const { employeesList, loading: employeeLoading, error } = useAllEmployees(); const [selectedEmployees, setSelectedEmployees] = useState([]); - const [searchText, setSearchText] = useState(""); + const [ searchText, setSearchText ] = useState( "" ); const handleAllocationData = Array.isArray(allocation) ? allocation : []; @@ -94,17 +96,19 @@ const MapUsers = ({ }); }; - const handleSubmit = () => { + const handleSubmit = () => + { + setAssignedLoading(true) const selected = selectedEmployees .filter((emp) => emp.isSelected) .map((emp) => ({ empID: emp.id, jobRoleId: emp.jobRoleId })); if (selected.length > 0) { - console.log(selected); onSubmit(selected); setSelectedEmployees([]); } else { showToast("Please select Employee", "error"); } + }; return ( <> @@ -112,14 +116,17 @@ const MapUsers = ({
-
- setSearchQuery(e.target.value)} - /> -
+ {(filteredData.length > 0 || + allocationEmployeesData.length > 0)&& ( +
+ setSearchQuery(e.target.value)} + /> +
+ )}
@@ -131,19 +138,22 @@ const MapUsers = ({ > - {(employeeLoading && allocationEmployeesData.length === 0 ) &&

Loading...

} + {employeeLoading && allocationEmployeesData.length === 0 && ( +

Loading...

+ )} {!employeeLoading && allocationEmployeesData.length === 0 && - filteredData.length === 0 &&

No employees available.

} - - {!employeeLoading && - allocationEmployeesData.length > 0 && filteredData.length === 0 && ( -

No matching employees found.

+

All employee assigned to Project.

)} - {filteredData.length > 0 && + {!employeeLoading && allocationEmployeesData.length > 0 && filteredData.length === 0 && ( +

No matching employees found.

+ )} + + {(filteredData.length > 0 || + allocationEmployeesData.length > 0) && filteredData.map((emp) => (
- + {(filteredData.length > 0 || + allocationEmployeesData.length > 0) && ( + + )} +