diff --git a/src/electron/api/axiosClient.ts b/src/electron/api/axiosClient.ts index 0060ea6..c4662a1 100644 --- a/src/electron/api/axiosClient.ts +++ b/src/electron/api/axiosClient.ts @@ -12,7 +12,7 @@ const httpsAgent = new https.Agent({ }); const api: AxiosInstance = axios.create({ - baseURL: 'https://daniela-nonprofessed-boastfully.ngrok-free.app/api/v1/va', // 🔁 your backend + baseURL: 'https://quality-friendly-goldfish.ngrok-free.app/api/v1/va', // 🔁 your backend httpsAgent // timeout: 10000, }); diff --git a/src/electron/utils/utilityFunctions.ts b/src/electron/utils/utilityFunctions.ts index 0a15c7d..c09a7ab 100644 --- a/src/electron/utils/utilityFunctions.ts +++ b/src/electron/utils/utilityFunctions.ts @@ -68,7 +68,7 @@ export const handleLogin = async (credentials: { email: string, password: string try { console.log("➡️ Calling API..."); const response = await axios.post( - 'https://daniela-nonprofessed-boastfully.ngrok-free.app/api/v1/va/login', + 'https://quality-friendly-goldfish.ngrok-free.app/api/v1/va/login', { userDetails: { ...credentials } }, { headers: { "ngrok-skip-browser-warning": 69420 }, httpsAgent } ); diff --git a/src/ui/layout/DashboardLayout.tsx b/src/ui/layout/DashboardLayout.tsx index 8ff0f2b..afd12cd 100644 --- a/src/ui/layout/DashboardLayout.tsx +++ b/src/ui/layout/DashboardLayout.tsx @@ -113,8 +113,8 @@ const DashboardLayout = () => { { label: "Dashboard", path: "/dashboard", icon: , exact: true }, { label: "Timesheet", path: "/dashboard/timesheet", icon: }, { label: "Leave & Adjust", path: "/dashboard/leave-adjustments", icon: }, - { label: "Schedule", path: "/dashboard/schedule", icon: }, - { label: "Pays Slips", path: "/dashboard/pays-slips", icon: }, + { label: "Schedule", path: "/dashboard/schedule", icon: }, + { label: "Pays Slips", path: "/dashboard/pays-slips", icon: }, { label: "Settings", path: "/dashboard/settings", icon: }, { label: "VPN", path: "/dashboard/vpn", icon: }, { label: "Help & Support", path: "/dashboard/help-support", icon: }, @@ -318,6 +318,7 @@ const DashboardLayout = () => { const socketRef = useRef(null); const intervalRef = useRef(null); + const lastAppsRef = useRef(null); const [isConnected, setIsConnected] = useState(false); useEffect(() => { @@ -525,6 +526,7 @@ const DashboardLayout = () => { } }; + const handleSocketConnect = async () => { const token = await window.electron.getToken("ACCESS_TOKEN"); @@ -536,7 +538,7 @@ const DashboardLayout = () => { if (!selectedProject?.projectId) return console.log(selectedProject?.projectId, "SelectedProject ID") - socketRef.current = io("https://daniela-nonprofessed-boastfully.ngrok-free.app", { + socketRef.current = io("https://quality-friendly-goldfish.ngrok-free.app", { transports: ["websocket"], secure: true, rejectUnauthorized: false, @@ -558,12 +560,56 @@ const DashboardLayout = () => { setIsConnected(true); // Start sending every 5 seconds + // intervalRef.current = setInterval(async () => { + // const apps = await window.electron.getRunningApps() + // socketRef.current?.emit("getVisibleApps", { token: await token, apps }); + // }, 5000); + }); + + // socketRef.current.on("startSendAppsDetails", async ({ apps }) => { + // socketRef.current?.emit("getVisibleApps", { token: await token, apps }); + // }); + + socketRef.current.on("startSendAppsDetails", async ({projId}) => { + if (projId !== selectedProject?.projectId) return; + console.log("▶️ startSendAppsDetails received"); + + // avoid multiple intervals + if (intervalRef.current) return; + intervalRef.current = setInterval(async () => { - const apps = await window.electron.getRunningApps() - socketRef.current?.emit("getVisibleApps", { token: await token, apps }); + const currentApps = await window.electron.getRunningApps(); + + // Compare with last sent data + const hasChanged = JSON.stringify(currentApps) !== JSON.stringify(lastAppsRef.current); + + if (hasChanged) { + lastAppsRef.current = currentApps; + + socketRef.current?.emit("getVisibleApps", { + token: await token, + apps: currentApps, + }); + } }, 5000); }); + socketRef.current.on("stopSendAppsDetails", async ({projId}) => { + if (projId !== selectedProject?.projectId) return; + console.log("⏹ stopSendAppsDetails received"); + + // clear the interval + if (intervalRef.current) { + clearInterval(intervalRef.current); + intervalRef.current = null; + } + + // Send final stop event to server + // socketRef.current?.emit("stopSendAppsDetails", { + // token: await token, + // }); + }); + socketRef.current.on("appToCapture", async ({ appTitle }) => { console.log("📸 Capture requested for:", appTitle); diff --git a/src/ui/pages/LeaveAndAdjustments/tabs/PtoLeaveTab.tsx b/src/ui/pages/LeaveAndAdjustments/tabs/PtoLeaveTab.tsx index e41ffbd..3b9a30a 100644 --- a/src/ui/pages/LeaveAndAdjustments/tabs/PtoLeaveTab.tsx +++ b/src/ui/pages/LeaveAndAdjustments/tabs/PtoLeaveTab.tsx @@ -198,7 +198,7 @@ const PtoLeaveTab: React.FC<{ if (result.success) { resetForm(); - alert("PTO submitted!"); + alert("PTO Request submitted!"); } else { setServerError(result.message || "Something went wrong"); } diff --git a/src/ui/pages/LeaveAndAdjustments/tabs/SickLeaveTab.tsx b/src/ui/pages/LeaveAndAdjustments/tabs/SickLeaveTab.tsx index 180e6ae..c64a501 100644 --- a/src/ui/pages/LeaveAndAdjustments/tabs/SickLeaveTab.tsx +++ b/src/ui/pages/LeaveAndAdjustments/tabs/SickLeaveTab.tsx @@ -188,7 +188,7 @@ const SickLeaveTab: React.FC<{ if (result.success) { resetForm(); - alert("SICK submitted!"); + alert("SICK leave applied!"); } else { setServerError(result.message || "Something went wrong"); }