From 2aae7194b72213f99d9796ba3dcd4b6d94114043 Mon Sep 17 00:00:00 2001 From: "pramod.mahajan" Date: Wed, 1 Oct 2025 13:00:38 +0530 Subject: [PATCH] implemented singlR --- .../Documents/DocumentFilterPanel.jsx | 4 +- src/components/Documents/DocumentSkeleton.jsx | 88 +- src/components/Documents/Documents.jsx | 2 +- src/components/Documents/DocumentsList.jsx | 12 +- src/components/Employee/EmpAttendance.jsx | 2 +- src/components/Employee/EmpDashboard.jsx | 8 +- src/components/Employee/EmployeeNav.jsx | 2 +- src/components/Layout/Header.jsx | 31 +- src/components/Project/ProjectCard.jsx | 8 +- src/components/Project/ProjectCardView.jsx | 108 ++- src/components/Project/ProjectListView.jsx | 27 +- src/hooks/useDocument.js | 5 +- src/pages/Directory/DirectoryPage.jsx | 20 +- src/pages/Directory/NoteFilterPanel.jsx | 4 +- src/pages/employee/EmployeeList.jsx | 768 +++++++++--------- src/pages/master/MasterPage.jsx | 5 +- src/pages/master/MasterTable.jsx | 6 +- src/services/signalRService.js | 186 ++--- 18 files changed, 628 insertions(+), 658 deletions(-) diff --git a/src/components/Documents/DocumentFilterPanel.jsx b/src/components/Documents/DocumentFilterPanel.jsx index 15a2cbf1..fdb6a3eb 100644 --- a/src/components/Documents/DocumentFilterPanel.jsx +++ b/src/components/Documents/DocumentFilterPanel.jsx @@ -189,12 +189,12 @@ const DocumentFilterPanel = ({ entityTypeId, onApply }) => {
-
diff --git a/src/components/Documents/DocumentSkeleton.jsx b/src/components/Documents/DocumentSkeleton.jsx index 94198326..6c1f7cb8 100644 --- a/src/components/Documents/DocumentSkeleton.jsx +++ b/src/components/Documents/DocumentSkeleton.jsx @@ -17,54 +17,56 @@ const SkeletonCell = ({ /> ); -export const DocumentTableSkeleton = ({ rows = 5 }) => { +export const DocumentTableSkeleton = ({ rows = 10 }) => { return ( + + + + + + + + + + -
NameDocument TypeUploaded ByUploaded onStatus
- - - - - - - - - + + {[...Array(rows)].map((_, idx) => ( + + {/* Name */} + - - {[...Array(rows)].map((_, idx) => ( - - {/* Name */} - + {/* Document Type */} + - {/* Document Type */} - - - {/* Uploaded By (Avatar + Name) */} - - - {/* Uploaded on */} - + + - {/* Status */} - - - ))} - -
NameDocument TypeUploaded ByUploaded onStatus
+ +
- - + + - - -
- - -
-
+ {/* Uploaded By (Avatar + Name) */} + +
+ -
- -
- + {/* Uploaded on */} + + + + + {/* Status */} + + + + + ))} + + ); }; diff --git a/src/components/Documents/Documents.jsx b/src/components/Documents/Documents.jsx index 8210bf58..bb1569d5 100644 --- a/src/components/Documents/Documents.jsx +++ b/src/components/Documents/Documents.jsx @@ -117,7 +117,7 @@ const Documents = ({ Document_Entity, Entity }) => { }, [Document_Entity]); return ( -
+
{/* Search */} diff --git a/src/components/Documents/DocumentsList.jsx b/src/components/Documents/DocumentsList.jsx index b56060ea..9576099d 100644 --- a/src/components/Documents/DocumentsList.jsx +++ b/src/components/Documents/DocumentsList.jsx @@ -82,9 +82,9 @@ const DocumentsList = ({ if (isLoading || isFetching) return ; if (isError) return
Error: {error?.message || "Something went wrong"}
; - if (isInitialEmpty) return
No documents found yet.
; - if (isSearchEmpty) return
No results found for "{debouncedSearch}"
; - if (isFilterEmpty) return
No documents match your filter.
; + if (isInitialEmpty) return
No documents found yet.
; + if (isSearchEmpty) return
No results found for "{debouncedSearch}"
; + if (isFilterEmpty) return
No documents match your filter.
; const handleDelete = () => { ActiveInActive( @@ -180,10 +180,10 @@ const DocumentsList = ({ /> )} -
+
- - + + {DocumentColumns.map((col) => ( - {updatedColumns.map((col) => ( -
{col.label} diff --git a/src/components/Employee/EmpAttendance.jsx b/src/components/Employee/EmpAttendance.jsx index 548471d8..db58261d 100644 --- a/src/components/Employee/EmpAttendance.jsx +++ b/src/components/Employee/EmpAttendance.jsx @@ -131,7 +131,7 @@ const EmpAttendance = ({ employee }) => { )} -
+
{ return ( <>
-
+
{" "}
-
+ {/*
@@ -29,7 +29,6 @@ const EmpDashboard = ({ profile }) => { className="d-flex mb-4 align-items-start flex-wrap" key={project.id} > - {/* Project Info */}
@@ -70,7 +69,6 @@ const EmpDashboard = ({ profile }) => {
- {/* Dates */}
@@ -79,7 +77,7 @@ const EmpDashboard = ({ profile }) => {
-
+
*/}
); diff --git a/src/components/Employee/EmployeeNav.jsx b/src/components/Employee/EmployeeNav.jsx index 8c25aa22..824949b7 100644 --- a/src/components/Employee/EmployeeNav.jsx +++ b/src/components/Employee/EmployeeNav.jsx @@ -24,7 +24,7 @@ const EmployeeNav = ({ onPillClick, activePill }) => { icon: "bx bx-file", label: "Documents", }, - { key: "activities", icon: "bx bx-grid-alt", label: "Activities" }, + // { key: "activities", icon: "bx bx-grid-alt", label: "Activities" }, ].filter(Boolean); return (
diff --git a/src/components/Layout/Header.jsx b/src/components/Layout/Header.jsx index 25056f77..1aa13c91 100644 --- a/src/components/Layout/Header.jsx +++ b/src/components/Layout/Header.jsx @@ -45,8 +45,9 @@ const Header = () => { pathname ); const isExpensePage = /^\/expenses$/.test(pathname); + const isEmployeePage = /^\/employees$/.test(pathname) - return !(isDirectoryPath || isProfilePage || isExpensePage); + return !(isDirectoryPath || isProfilePage || isExpensePage || isEmployeePage); }; const allowedProjectStatusIds = [ "603e994b-a27f-4e5d-a251-f3d69b0498ba", @@ -83,7 +84,7 @@ const Header = () => { currentProjectDisplayName = projectNames[0].name; } else { if (selectedProject === null) { - currentProjectDisplayName = "All Projects"; + currentProjectDisplayName = projectNames[0].name; } else { const selectedProjectObj = projectNames.find( (p) => p?.id === selectedProject @@ -135,14 +136,14 @@ const Header = () => { const newProjectHandler = useCallback( async (msg) => { - if (HasManageProjectPermission && msg.keyword === "Create_Project") { + if ( msg.keyword === "Create_Project") { await fetchData(); } else if (projectNames?.some((item) => item.id === msg.response.id)) { await fetchData(); } cacheData("hasReceived", false); }, - [HasManageProjectPermission, projectNames, fetchData] + [ projectNames, fetchData] ); useEffect(() => { @@ -212,7 +213,7 @@ const Header = () => { className="dropdown-menu" style={{ overflow: "auto", maxHeight: "300px" }} > - {isDashboardPath && ( + {isProjectPath && (
  • -
  • +
  • + +
  • {/* )} */}
  • {
  • -
    + diff --git a/src/components/Project/ProjectCardView.jsx b/src/components/Project/ProjectCardView.jsx index 1108120c..0d094a35 100644 --- a/src/components/Project/ProjectCardView.jsx +++ b/src/components/Project/ProjectCardView.jsx @@ -1,70 +1,62 @@ -import React from 'react' -import { useProjects } from '../../hooks/useProjects' -import Loader from '../common/Loader' -import ProjectCard from './ProjectCard' - -const ProjectCardView = ({currentItems,setCurrentPage,totalPages }) => { - +import React from "react"; +import { useProjects } from "../../hooks/useProjects"; +import Loader from "../common/Loader"; +import ProjectCard from "./ProjectCard"; +const ProjectCardView = ({ currentItems, setCurrentPage, totalPages }) => { return ( +
    + {currentItems.length === 0 && ( +

    No projects found.

    + )} -
    + {currentItems.map((project) => ( + + ))} - { currentItems.length === 0 && ( -

    No projects found.

    - )} - - {currentItems.map((project) => ( - - ))} - - - { totalPages > 1 && ( -
    - - ) -} + ))} +
  • + +
  • + + + )} +
    + ); +}; -export default ProjectCardView +export default ProjectCardView; diff --git a/src/components/Project/ProjectListView.jsx b/src/components/Project/ProjectListView.jsx index 2e717163..8a21e83c 100644 --- a/src/components/Project/ProjectListView.jsx +++ b/src/components/Project/ProjectListView.jsx @@ -26,9 +26,8 @@ const ProjectListView = ({ const navigate = useNavigate(); const { setMangeProject } = useProjectContext(); // const { data, isLoading, isError, error } = useProjects(); - // check Permissions - const canManageProject = useHasUserPermission(MANAGE_PROJECT); + // const canManageProject = useHasUserPermission(MANAGE_PROJECT); const projectColumns = [ { @@ -125,11 +124,15 @@ const ProjectListView = ({ }, ]; - const handleViewActivities = (project) => { - dispatch(setProjectId(project)); - navigate(`/activities/records?project=${project}`); - }; + // const handleViewActivities = (project) => { + // dispatch(setProjectId(project)); + // navigate(`/activities/records?project=${project}`); + // }; + const handleMoveDetails = (project) => { + dispatch(setProjectId(project)); + navigate("/projects/details"); + }; return (
    @@ -158,11 +161,7 @@ const ProjectListView = ({ : project[col.key] || "N/A"} ))} - diff --git a/src/hooks/useDocument.js b/src/hooks/useDocument.js index 5569d878..92562cd6 100644 --- a/src/hooks/useDocument.js +++ b/src/hooks/useDocument.js @@ -120,7 +120,7 @@ export const useUploadDocument = (onSuccessCallBack) => { DocumentRepository.uploadDocument(DocumentPayload), onSuccess: (data, variables) => { queryClient.invalidateQueries({ queryKey: ["DocumentList"] }); - + queryClient.invalidateQueries({ queryKey: ["Document"] }); if (onSuccessCallBack) onSuccessCallBack(); }, onError: (error) => { @@ -141,7 +141,7 @@ export const useUpdateDocument = (onSuccessCallBack) => { onSuccess: (data, variables) => { const { documentId } = variables; queryClient.invalidateQueries({ queryKey: ["DocumentList"] }); - queryClient.invalidateQueries({ queryKey: ["Document", documentId] }); + queryClient.invalidateQueries({ queryKey: ["Document"] }); if (onSuccessCallBack) onSuccessCallBack(); }, onError: (error) => { @@ -187,6 +187,7 @@ export const useActiveInActiveDocument = ()=>{ onSuccess: (data, variables) => { const {isActive} = variables; queryClient.invalidateQueries({ queryKey: ["DocumentList"] }); + queryClient.invalidateQueries({ queryKey: ["Document"] }); showToast(`Document ${isActive ? "restored":"Deleted"} successfully`,"success") }, onError: (error) => { diff --git a/src/pages/Directory/DirectoryPage.jsx b/src/pages/Directory/DirectoryPage.jsx index ed092e82..744f3460 100644 --- a/src/pages/Directory/DirectoryPage.jsx +++ b/src/pages/Directory/DirectoryPage.jsx @@ -44,7 +44,7 @@ export default function DirectoryPage({ IsPage = true, projectId = null }) { const [searchNote, setSearchNote] = useState(""); const [activeTab, setActiveTab] = useState("notes"); const { setActions } = useFab(); - const [gridView, setGridView] = useState(false); + const [gridView, setGridView] = useState(true); const [isOpenBucket, setOpenBucket] = useState(false); const [isManageContact, setManageContact] = useState({ isOpen: false, @@ -185,14 +185,7 @@ export default function DirectoryPage({ IsPage = true, projectId = null }) { value={searchContact} onChange={(e) => setsearchContact(e.target.value)} /> - + + +
    diff --git a/src/pages/Directory/NoteFilterPanel.jsx b/src/pages/Directory/NoteFilterPanel.jsx index 8a492994..87abd52d 100644 --- a/src/pages/Directory/NoteFilterPanel.jsx +++ b/src/pages/Directory/NoteFilterPanel.jsx @@ -60,12 +60,12 @@ const NoteFilterPanel = ({ onApply, clearFilter }) => {
    -
    diff --git a/src/pages/employee/EmployeeList.jsx b/src/pages/employee/EmployeeList.jsx index 3271af47..14ddf2d5 100644 --- a/src/pages/employee/EmployeeList.jsx +++ b/src/pages/employee/EmployeeList.jsx @@ -51,11 +51,7 @@ const EmployeeList = () => { const Manage_Employee = useHasUserPermission(MANAGE_EMPLOYEES); const { employees, loading, setLoading, error, recallEmployeeData } = - useEmployeesAllOrByProjectId( - showAllEmployees, - null, - showInactive - ); + useEmployeesAllOrByProjectId(showAllEmployees, null, showInactive); const [employeeList, setEmployeeList] = useState([]); const [modelConfig, setModelConfig] = useState(); @@ -204,22 +200,16 @@ const EmployeeList = () => { setCurrentPage((prevPage) => (prevPage !== 1 ? 1 : prevPage)); } - }, [loading, employees, showAllEmployees]); - - + }, [loading, employees, showAllEmployees]); const handler = useCallback( (msg) => { if (employees.some((item) => item.id == msg.employeeId)) { setEmployeeList([]); - recallEmployeeData( - showInactive, - null, - showAllEmployees - ); + recallEmployeeData(showInactive, null, showAllEmployees); } }, - [employees, showInactive, showAllEmployees] + [employees, showInactive, showAllEmployees] ); useEffect(() => { @@ -289,18 +279,16 @@ const EmployeeList = () => { {ViewTeamMember ? ( //
    -
    -
    -
    -
    - {/* Switches: All Employees + Inactive */} -
    - {/* All Employees Switch */} - {/* {ViewAllEmployee && ( +
    +
    +
    + {/* Switches: All Employees + Inactive */} +
    + {/* All Employees Switch */} + {/* {ViewAllEmployee && (
    {
    )} */} - {/* Show Inactive Employees Switch */} - {/* {showAllEmployees && ( */} -
    - setShowInactive(e.target.checked)} - /> - -
    - {/* )} */} -
    - - {/* Right side: Search + Export + Add Employee */} -
    - {/* Search Input - ALWAYS ENABLED */} -
    - -
    - - {/* Export Dropdown */} - - - {/* Add Employee Button */} - {Manage_Employee && ( - - )} + {/* Show Inactive Employees Switch */} + {/* {showAllEmployees && ( */} +
    + setShowInactive(e.target.checked)} + /> +
    + {/* )} */}
    -
    +
      -
    • +
    • handleMoveDetails(project.id)}> Modify
    • -
    • handleViewActivities(project.id)}> + {/*
    • handleViewActivities(project.id)}> Activities -
    • + */}
    - - - - - - + /> + + - - - - - - - {loading && ( - - - - )} - {/* Conditional messages for no data or no search results */} - {!loading && - displayData?.length === 0 && - searchText && - !showAllEmployees ? ( - - - - ) : null} - {!loading && - displayData?.length === 0 && - (!searchText || showAllEmployees) ? ( - - - - ) : null} + Print + + +
  • + handleExport("csv")} + > + CSV + +
  • +
  • + handleExport("excel")} + > + Excel + +
  • +
  • + handleExport("pdf")} + > + PDF + +
  • + + - {/* Render current items */} - {currentItems && - !loading && - currentItems.map((item) => ( - - - - {Manage_Employee && ( - - )} - - ))} - -
    + {/* Search Input - ALWAYS ENABLED */} +
    +
    -
    Email
    -
    -
    Contact
    -
    -
    Designation
    -
    - Joining Date - - Status - - Actions -
    -

    Loading...

    -
    - - '{searchText}' employee not found - {" "} -
    + +
    - + + + + + + + + + + + + + + + + {loading && ( + + + + )} + {/* Conditional messages for no data or no search results */} + {!loading && + displayData?.length === 0 && + searchText ? ( + + + + ) : null} + {!loading && + displayData?.length === 0 && + (!searchText ) ? ( + + + + ) : null} + + {/* Render current items */} + {currentItems && + !loading && + currentItems.map((item) => ( + + + + + + + + + {Manage_Employee && ( + - - - + )} + + ))} + +
    +
    Name
    +
    +
    Email
    +
    +
    Contact
    +
    +
    Designation
    +
    + Joining Date + + Status + + Actions +
    +

    Loading...

    +
    +
    + + '{searchText}' employee not found + {" "} +
    +
    +
    {showInactive ? "No In-active Employeee Found" : "No Employeee Found" }
    +
    + + + {item.email ? ( + + + {item.email} + + ) : ( + - + )} + + + + {item.phoneNumber} + + + + + {item.jobRole || "Not Assign Yet"} + + + {moment(item.joiningDate)?.format("DD-MMM-YYYY")} + + {showInactive ? ( + + Inactive + + ) : ( + + Active + + )} + +
    + +
    + {/* View always visible */} + + + {/* If ACTIVE employee */} + {item.isActive && ( + <> + + + {/* Suspend only when active */} + {item.isActive && ( + + )} + + + + )} + + {/* If INACTIVE employee AND inactive toggle is ON */} + {!item.isActive && showInactive && ( + + )}
    - {item.email ? ( - - - {item.email} - - ) : ( - - - - - )} - - - - {item.phoneNumber} - - - - - {item.jobRole || "Not Assign Yet"} - -
    -
    - {moment(item.joiningDate)?.format("DD-MMM-YYYY")} - - {showInactive ? ( - - Inactive - - ) : ( - - Active - - )} - -
    - -
    - {/* View always visible */} - - - {/* If ACTIVE employee */} - {item.isActive && ( - <> - - - {/* Suspend only when active */} - {item.isActive && ( - - )} - - - - )} - - {/* If INACTIVE employee AND inactive toggle is ON */} - {!item.isActive && showInactive && ( - - )} -
    -
    -
    - - {displayData.length > 0 && ( - - )} -
    + {displayData.length > 0 && ( + + )}
    ) : ( diff --git a/src/pages/master/MasterPage.jsx b/src/pages/master/MasterPage.jsx index a206b913..e10d2e8d 100644 --- a/src/pages/master/MasterPage.jsx +++ b/src/pages/master/MasterPage.jsx @@ -161,8 +161,8 @@ const MasterPage = () => { data={[{ label: "Home", link: "/dashboard" }, { label: "Masters" }]} /> -
    -
    + +
    { handleModalData={handleModalData} />
    -
    diff --git a/src/pages/master/MasterTable.jsx b/src/pages/master/MasterTable.jsx index 8facfdb7..b0e52681 100644 --- a/src/pages/master/MasterTable.jsx +++ b/src/pages/master/MasterTable.jsx @@ -109,11 +109,11 @@ const MasterTable = ({ data, columns, loading, handleModalData }) => { {currentItems.length > 0 ? ( currentItems.map((item, index) => (
    - + +
    + {col.key === "description" ? ( item[col.key] !== undefined && item[col.key] !== null ? ( diff --git a/src/services/signalRService.js b/src/services/signalRService.js index 3d9d40b1..cbf29fd1 100644 --- a/src/services/signalRService.js +++ b/src/services/signalRService.js @@ -32,100 +32,104 @@ export function startSignalR(loggedUser) { .toISOString() .split("T")[0]; connection.on("NotificationEventHandler", (data) => { - if (data.loggedInUserId != loggedUser?.employeeInfo.id) { - // console.log("Notification received:", data); - // if action taken on attendance module - if (data.keyword == "Attendance") { - const checkIn = data.response.checkInTime.substring(0, 10); - if (today === checkIn) { - eventBus.emit("attendance", data); - } - var onlyDate = Number(checkIn.substring(8, 10)); + const { loggedInUserId, keyword, response, employeeList, numberOfImages } = data; + const loggedInId = loggedUser?.employeeInfo?.id; - var afterTwoDay = - checkIn.substring(0, 8) + (onlyDate + 2).toString().padStart(2, "0"); - if ( - afterTwoDay <= today && - (data.response.activity == 4 || data.response.activity == 5) - ) { - eventBus.emit("regularization", data); - } - eventBus.emit("attendance_log", data); - } - if(data.keyword == "Expanse"){ - queryClient.invalidateQueries({queryKey:["Expenses"]}) - } - // if create or update project - if ( - data.keyword == "Create_Project" || - data.keyword == "Update_Project" - ) { - // clearCacheKey("projectslist"); - queryClient.invalidateQueries(['projectslist']); - eventBus.emit("project", data); - } + if (loggedInUserId === loggedInId) return; - // if assign or deassign employee to any project - if (data.keyword == "Assign_Project") { - if ( - data.employeeList.some((item) => item === loggedUser?.employeeInfo.id) - ) { - try { - cacheData("hasReceived", false); - eventBus.emit("assign_project_one", data); - } catch (e) { - // console.error("Error in cacheData:", e); - } - } - eventBus.emit("assign_project_all", data); - } - // if created or updated infra - if (data.keyword == "Infra") { - 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 - if (data.keyword == "Employee") { - // clearCacheKey("employeeListByProject"); - // clearCacheKey("allEmployeeList"); - // clearCacheKey("allInactiveEmployeeList"); - // clearCacheKey("employeeProfile"); - clearCacheKey("Attendance"); - clearCacheKey("regularizedList") - clearCacheKey("AttendanceLogs") - - // ---we can do also---- - // queryClient.removeQueries(['allEmployee', true]); - // but best practies is refetch - queryClient.invalidateQueries(['allEmployee', true]); - queryClient.invalidateQueries(['allEmployee', false]); - queryClient.invalidateQueries(['employeeProfile', data.response?.employeeId]); - queryClient.invalidateQueries(['employeeListByProject']); // optional if scope - eventBus.emit("employee", data); - } - - if (data.keyword == "Task_Report") { - if(data.numberOfImages > 0){ - eventBus.emit("image_gallery", data); - } - } - if (data.keyword == "Task_Comment") { - if(data.numberOfImages > 0){ - eventBus.emit("image_gallery", data); - } - } + // ---- Handlers for invalidate or remove ---- + const queryInvalidators = { + Expanse: () => { + queryClient.invalidateQueries({ queryKey: ["Expenses"] }), + queryClient.invalidateQueries({ queryKey: ["Expense"] }) + }, + Create_Project: () => queryClient.invalidateQueries(["projectslist"]), + Update_Project: () => queryClient.invalidateQueries(["projectslist"]), + Infra: () => queryClient.removeQueries({ queryKey: ["ProjectInfra"] }), + Task_Report: () => queryClient.invalidateQueries({ queryKey: ["Infra"] }), + WorkItem: () => queryClient.invalidateQueries({ queryKey: ["WorkItems"] }), + Directory_Notes:()=>{ + queryClient.invalidateQueries({queryKey:["directoryNotes"]}) + queryClient.invalidateQueries({queryKey:["Notes"]}) + }, + Directory_Buckets:()=>{ + queryClient.invalidateQueries({queryKey:["bucketList"]}) + }, + Directory:()=>{ + queryClient.invalidateQueries({queryKey:["contacts"]}) + queryClient.invalidateQueries({queryKey:["Contact"]}) + queryClient.invalidateQueries({queryKey:["ContactProfile"]}) } - }); + + }; + + // ---- Keyword based event emitters ---- + const emitters = { + employee: () => eventBus.emit("employee", data), + project: () => eventBus.emit("project", data), + infra: () => eventBus.emit("infra", data), + assign_project_all: () => eventBus.emit("assign_project_all", data), + image_gallery: () => eventBus.emit("image_gallery", data), + }; + + // ---- Handle Attendance ---- + if (keyword === "Attendance") { + const checkIn = response.checkInTime.substring(0, 10); + if (today === checkIn) eventBus.emit("attendance", data); + + const onlyDate = Number(checkIn.substring(8, 10)); + const afterTwoDay = + checkIn.substring(0, 8) + (onlyDate + 2).toString().padStart(2, "0"); + + if ( + afterTwoDay <= today && + (response.activity === 4 || response.activity === 5) + ) { + eventBus.emit("regularization", data); + } + eventBus.emit("attendance_log", data); + } + + // ---- Invalidate/Remove cache by keywords ---- + if (queryInvalidators[keyword]) { + queryInvalidators[keyword](); + } + + // ---- Project creation/update ---- + if (keyword === "Create_Project" || keyword === "Update_Project") { + emitters.project(); + } + + // ---- Assign/deassign project ---- + if (keyword === "Assign_Project") { + if (employeeList?.includes(loggedInId)) { + try { + cacheData("hasReceived", false); + eventBus.emit("assign_project_one", data); + } catch {} + } + emitters.assign_project_all(); + } + + // ---- Employee update ---- + if (keyword === "Employee") { + clearCacheKey("Attendance"); + clearCacheKey("regularizedList"); + clearCacheKey("AttendanceLogs"); + + queryClient.invalidateQueries(["allEmployee", true]); + queryClient.invalidateQueries(["allEmployee", false]); + queryClient.invalidateQueries(["employeeProfile", response?.employeeId]); + queryClient.invalidateQueries(["employeeListByProject"]); + + emitters.employee(); + } + + // ---- Image related events ---- + if (["Task_Report", "Task_Comment"].includes(keyword) && numberOfImages > 0) { + emitters.image_gallery(); + } +}); connection .start();