added signalr events
This commit is contained in:
parent
cb7df469c2
commit
87edce4c3d
@ -11,7 +11,7 @@ import {
|
||||
getCachedData,
|
||||
} from "../../../slices/apiDataManager";
|
||||
|
||||
const InfraTable = ({ buildings, projectId, signalRHandler }) => {
|
||||
const InfraTable = ({ buildings, projectId}) => {
|
||||
const [projectBuilding, setProjectBuilding] = useState([]);
|
||||
const [expandedBuildings, setExpandedBuildings] = useState([]);
|
||||
const [showFloorModal, setShowFloorModal] = useState(false);
|
||||
@ -113,34 +113,34 @@ const InfraTable = ({ buildings, projectId, signalRHandler }) => {
|
||||
}
|
||||
}, [buildings]);
|
||||
|
||||
const handler = useCallback(
|
||||
(msg) => {
|
||||
if (msg.projectIds.some((item) => item == projectId)) {
|
||||
try {
|
||||
ProjectRepository.getProjectByprojectId(projectId)
|
||||
.then((response) => {
|
||||
cacheData("projectInfo", {
|
||||
projectId: projectId,
|
||||
data: response.data,
|
||||
});
|
||||
setProjectBuilding(response?.data?.buildings);
|
||||
signalRHandler?.(response?.data);
|
||||
showToast(msg.message, "info");
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
},
|
||||
[buildings]
|
||||
);
|
||||
useEffect(() => {
|
||||
eventBus.on("infra", handler);
|
||||
return () => eventBus.off("infra", handler);
|
||||
}, [handler]);
|
||||
// const handler = useCallback(
|
||||
// (msg) => {
|
||||
// if (msg.projectIds.some((item) => item == projectId)) {
|
||||
// try {
|
||||
// ProjectRepository.getProjectByprojectId(projectId)
|
||||
// .then((response) => {
|
||||
// cacheData("projectInfo", {
|
||||
// projectId: projectId,
|
||||
// data: response.data,
|
||||
// });
|
||||
// setProjectBuilding(response?.data?.buildings);
|
||||
// signalRHandler?.(response?.data);
|
||||
// showToast(msg.message, "info");
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// console.error(error);
|
||||
// });
|
||||
// } catch (e) {
|
||||
// console.error(e);
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// [buildings]
|
||||
// );
|
||||
// useEffect(() => {
|
||||
// eventBus.on("infra", handler);
|
||||
// return () => eventBus.off("infra", handler);
|
||||
// }, [handler]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
@ -42,12 +42,12 @@ const ProjectInfra = ( {data, onDataChange, eachSiteEngineer} ) =>
|
||||
setProject(projectInfra);
|
||||
}, [data, projects_Details]);
|
||||
|
||||
useEffect(() => {
|
||||
if (reloadedData) {
|
||||
refetch();
|
||||
dispatch(refreshData(false));
|
||||
}
|
||||
}, [reloadedData]);
|
||||
// useEffect(() => {
|
||||
// if (reloadedData) {
|
||||
// refetch();
|
||||
// dispatch(refreshData(false));
|
||||
// }
|
||||
// }, [reloadedData]);
|
||||
|
||||
const signalRHandler = (response) => {
|
||||
setProject(response);
|
||||
@ -130,7 +130,7 @@ const ProjectInfra = ( {data, onDataChange, eachSiteEngineer} ) =>
|
||||
buildings={projectInfra}
|
||||
projectId={projectId}
|
||||
// handleFloor={submitData}
|
||||
signalRHandler ={signalRHandler}
|
||||
// signalRHandler ={signalRHandler}
|
||||
/>
|
||||
)}
|
||||
{!isLoading && projectInfra?.length == 0 && <div className="mt-5"><p>No Infra Avaiable</p></div>}
|
||||
|
@ -194,6 +194,7 @@ export const useUpdateEmployee = () =>
|
||||
queryClient.invalidateQueries( {queryKey:[ 'allEmployee', isAllEmployee ] });
|
||||
// queryClient.invalidateQueries(['employeeProfile', id]);
|
||||
queryClient.invalidateQueries( {queryKey: [ 'projectEmployees' ]} );
|
||||
queryClient.removeQueries( {queryKey: [ "empListByProjectAllocated" ]} );
|
||||
|
||||
// queryClient.invalidateQueries( {queryKey:[ 'employeeListByProject']} );
|
||||
showToast( `Employee ${ id ? 'updated' : 'created' } successfully`, 'success' );
|
||||
|
@ -79,8 +79,17 @@ export function startSignalR(loggedUser) {
|
||||
}
|
||||
// if created or updated infra
|
||||
if (data.keyword == "Infra") {
|
||||
clearCacheKey("projectInfo");
|
||||
eventBus.emit("infra", data);
|
||||
queryClient.removeQueries({queryKey:["ProjectInfra"]})
|
||||
// eventBus.emit("infra", data);
|
||||
}
|
||||
if (data.keyword == "Task_Report") {
|
||||
queryClient.removeQueries({queryKey:["Infra"]})
|
||||
// eventBus.emit("infra", data);
|
||||
}
|
||||
|
||||
if ( data.keyword == "WorkItem" )
|
||||
{
|
||||
queryClient.removeQueries({queryKey:["WorkItems"]})
|
||||
}
|
||||
|
||||
// if created or updated Employee
|
||||
|
Loading…
x
Reference in New Issue
Block a user