React Query Integration for Server State Sync in Clinet #245

Merged
admin merged 60 commits from react-query into main 2025-07-11 11:32:19 +00:00
3 changed files with 7 additions and 4 deletions
Showing only changes of commit d818ea9265 - Show all commits

View File

@ -7,6 +7,7 @@ import {useHasUserPermission} from "../../hooks/useHasUserPermission";
import {MANAGE_PROJECT} from "../../utils/constants"; import {MANAGE_PROJECT} from "../../utils/constants";
import GlobalModel from "../common/GlobalModel"; import GlobalModel from "../common/GlobalModel";
import ManageProjectInfo from "./ManageProjectInfo"; import ManageProjectInfo from "./ManageProjectInfo";
import {useQueryClient} from "@tanstack/react-query";
const AboutProject = () => const AboutProject = () =>
{ {
const [ IsOpenModal, setIsOpenModal ] = useState( false ) const [ IsOpenModal, setIsOpenModal ] = useState( false )
@ -15,7 +16,8 @@ const AboutProject = () =>
{ {
setIsOpenModal(false) setIsOpenModal(false)
} }
}) } )
const ClientQuery = useQueryClient()
const {projectId} = useParams(); const {projectId} = useParams();
const manageProject = useHasUserPermission(MANAGE_PROJECT); const manageProject = useHasUserPermission(MANAGE_PROJECT);
const {projects_Details, isLoading, error,refetch} = useProjectDetails( projectId ) const {projects_Details, isLoading, error,refetch} = useProjectDetails( projectId )
@ -23,9 +25,10 @@ const AboutProject = () =>
{ {
if ( projects_Details?.id ) if ( projects_Details?.id )
{ {
ClientQuery.invalidateQueries({queryKey:["projectInfo"]})
UpdateProjectDetails({ projectId: projects_Details?.id,updatedData: updatedProject, UpdateProjectDetails({ projectId: projects_Details?.id,updatedData: updatedProject,
} ); } );
refetch()
} }
}; };
return ( return (

View File

@ -108,6 +108,7 @@ export const useReportTask = ( {onSuccessCallback, onErrorCallback} = {} ) =>
const {workAreaId} = variables; const {workAreaId} = variables;
queryClient.invalidateQueries( {queryKey: [ "taskList" ]} ); queryClient.invalidateQueries( {queryKey: [ "taskList" ]} );
queryClient.invalidateQueries( {queryKey: [ "WorkItems", workAreaId ]} ); queryClient.invalidateQueries( {queryKey: [ "WorkItems", workAreaId ]} );
queryClient.invalidateQueries( {queryKey: [ 'ProjectsList' ]} );
showToast( "Task Reported Successfully.", "success" ); showToast( "Task Reported Successfully.", "success" );
if (onSuccessCallback) onSuccessCallback(data); if (onSuccessCallback) onSuccessCallback(data);
}, },

View File

@ -109,8 +109,7 @@ export function startSignalR(loggedUser) {
queryClient.invalidateQueries(['allEmployee', false]); queryClient.invalidateQueries(['allEmployee', false]);
queryClient.invalidateQueries(['employeeProfile', data.response?.employeeId]); queryClient.invalidateQueries(['employeeProfile', data.response?.employeeId]);
queryClient.invalidateQueries(['employeeListByProject']); // optional if scope queryClient.invalidateQueries(['employeeListByProject']); // optional if scope
queryClient eventBus.emit("employee", data);
eventBus.emit("employee", data);
} }
if (data.keyword == "Task_Report") { if (data.keyword == "Task_Report") {