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 = ({
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) => (