diff --git a/src/electron/ipc/ipcHandler.ts b/src/electron/ipc/ipcHandler.ts index c97479c..8db0718 100644 --- a/src/electron/ipc/ipcHandler.ts +++ b/src/electron/ipc/ipcHandler.ts @@ -274,6 +274,27 @@ ipcMain.handle("change-password", async (event, data) => { }); +ipcMain.handle("get-project-summary", async (_, { projectId, date }) => { + try { + const url = `/timesheet/summary/${projectId}/${date}`; + console.log("📡 Fetching summary:", url); + + const res = await api.get(url); + return { + success: true, + data: res.data, + }; + } catch (error: any) { + console.error("❌ Error fetching summary:", error.message); + return { + success: false, + message: error.response?.data?.message || "Something went wrong", + }; + } +}); + + + export const sendTokenExpired = () => { console.log("⚠️ Sending token-expired event to renderer"); diff --git a/src/electron/preload.cts b/src/electron/preload.cts index 08a3d6d..c9d34d2 100644 --- a/src/electron/preload.cts +++ b/src/electron/preload.cts @@ -43,6 +43,10 @@ contextBridge.exposeInMainWorld('electron', { }); }, + + getProjectSummary: (projectId: string, date: string) => + ipcRenderer.invoke("get-project-summary", { projectId, date }), + } satisfies Window['electron']); // function ipcInvoke( diff --git a/src/ui/layout/DashboardLayout.tsx b/src/ui/layout/DashboardLayout.tsx index ca9c8bb..6763099 100644 --- a/src/ui/layout/DashboardLayout.tsx +++ b/src/ui/layout/DashboardLayout.tsx @@ -548,7 +548,7 @@ const DashboardLayout = () => { const hrs = Math.floor(seconds / 3600); const mins = Math.floor((seconds % 3600) / 60); const secs = seconds % 60; - return `${hrs}h ${mins}m ${secs}s`; + return `${hrs}h ${mins}m`; }; const toggleWindowSize = useRef(true); @@ -651,13 +651,14 @@ const DashboardLayout = () => { ))} - + } {/* Main Content */} diff --git a/src/ui/pages/Dashboard.tsx b/src/ui/pages/Dashboard.tsx index 30b55b2..0bcd51f 100644 --- a/src/ui/pages/Dashboard.tsx +++ b/src/ui/pages/Dashboard.tsx @@ -41,7 +41,8 @@ const formatTime = (seconds: number) => { const hrs = Math.floor(seconds / 3600); const mins = Math.floor((seconds % 3600) / 60); const secs = seconds % 60; - return `${hrs}h ${mins}m ${secs}s`; + // return `${hrs}h ${mins}m ${secs}s`; + return `${hrs}h ${mins}m `; }; // Widget Component @@ -95,6 +96,17 @@ const Dashboard: React.FC = () => { ? projectTrackingMap.get(selectedProject.projectId) : null; + const formatWorkTime = (time: string) => { + if (!time) return "0h 0m"; + + // Example input: "0h 2m 29s" + const parts = time.split(" "); + + // Always return first two parts: ["0h", "2m"] + return parts.slice(0, 2).join(" "); + }; + + return (
{/* Header */} @@ -263,7 +275,7 @@ const Dashboard: React.FC = () => { {index + 1} {project.projectName} - {project.totalWorkTime || "0h 0m 0s"} + {formatWorkTime(project.totalWorkTime)}