sec remove show min
This commit is contained in:
parent
44d790abab
commit
d6481a0c27
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@ contextBridge.exposeInMainWorld('electron', {
|
|||
});
|
||||
},
|
||||
|
||||
|
||||
getProjectSummary: (projectId: string, date: string) =>
|
||||
ipcRenderer.invoke("get-project-summary", { projectId, date }),
|
||||
|
||||
} satisfies Window['electron']);
|
||||
|
||||
// function ipcInvoke<Key extends keyof EventPayloadMapping>(
|
||||
|
|
|
|||
|
|
@ -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 = () => {
|
|||
</NavLink>
|
||||
</div>
|
||||
))}
|
||||
<button
|
||||
|
||||
{!isTracking && <button
|
||||
onClick={handleLogout}
|
||||
className="flex items-center justify-center w-10 h-10 rounded-lg transition-all duration-150 hover:bg-error/10 text-error hover:text-error mt-auto cursor-pointer tooltip tooltip-right "
|
||||
data-tip={"Logout"}
|
||||
>
|
||||
<LogOut size={18} />
|
||||
</button>
|
||||
</button>}
|
||||
</aside>
|
||||
|
||||
{/* Main Content */}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<main className="flex-1 overflow-hidden no-scrollbar max-h-screen">
|
||||
{/* Header */}
|
||||
|
|
@ -263,7 +275,7 @@ const Dashboard: React.FC = () => {
|
|||
<td className="text-xs opacity-70">{index + 1}</td>
|
||||
<td className="font-medium">{project.projectName}</td>
|
||||
<td className="font-mono text-xs">
|
||||
{project.totalWorkTime || "0h 0m 0s"}
|
||||
{formatWorkTime(project.totalWorkTime)}
|
||||
</td>
|
||||
<td>
|
||||
<button
|
||||
|
|
|
|||
|
|
@ -172,35 +172,33 @@ const LeaveAndAdjustments: React.FC = () => {
|
|||
|
||||
|
||||
|
||||
// const fetchLogs = async () => {
|
||||
// const res = await window.electron.getProjectLogs(
|
||||
// selectedProjectId,
|
||||
// selectedDate || undefined,
|
||||
// selectedDate || undefined,
|
||||
// );
|
||||
const fetchLogs = async () => {
|
||||
try {
|
||||
console.log("Sending =>", selectedProjectId, selectedDate);
|
||||
|
||||
const res = await window.electron.getProjectSummary(
|
||||
selectedProjectId,
|
||||
selectedDate
|
||||
);
|
||||
|
||||
console.log("📥 Summary Response:", res);
|
||||
|
||||
// if (res.success) {
|
||||
// console.log("✅ Logs: fetchLogs", res);
|
||||
|
||||
// // Safely extract time if from/to exist
|
||||
// const fromTime = res.from ? new Date(res.from).toISOString().slice(11, 16) : "";
|
||||
// const toTime = res.to ? new Date(res.to).toISOString().slice(11, 16) : "";
|
||||
|
||||
// setPtoLeave({
|
||||
// fromDate: fromTime,
|
||||
// toDate: toTime,
|
||||
// });
|
||||
// // setProjectLogs(res.data); // <-- store logs in state
|
||||
// } else {
|
||||
// console.warn("⚠️ Failed to fetch project logs");
|
||||
// console.warn("⚠️ Summary API failed:", res.message);
|
||||
// }
|
||||
// };
|
||||
} catch (err) {
|
||||
console.error("❌ Error fetching project summary:", err);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// useEffect(() => {
|
||||
// if (selectedProjectId && selectedDate) {
|
||||
// fetchLogs()
|
||||
// }
|
||||
// }, [selectedProjectId, selectedDate])
|
||||
useEffect(() => {
|
||||
if (selectedProjectId && selectedDate) {
|
||||
fetchLogs()
|
||||
}
|
||||
}, [selectedProjectId, selectedDate])
|
||||
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -92,6 +92,16 @@ const Timesheets: React.FC = () => {
|
|||
}
|
||||
};
|
||||
|
||||
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 (
|
||||
|
|
@ -154,7 +164,7 @@ const Timesheets: React.FC = () => {
|
|||
<tr key={entry.projectId}>
|
||||
<td>{index+1}</td>
|
||||
<td>{entry.projectName}</td>
|
||||
<td>{entry.totalWorkTime}</td>
|
||||
<td>{formatWorkTime(entry.totalWorkTime)}</td>
|
||||
<td>
|
||||
<button
|
||||
onClick={() => handleViewLogs(entry.projectId, entry.projectName)}
|
||||
|
|
|
|||
|
|
@ -144,6 +144,9 @@ interface Window {
|
|||
|
||||
|
||||
onTokenExpired: (callback: () => void) => void;
|
||||
|
||||
|
||||
getProjectSummary: (projectId: string, date: string) => Promise<any>;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue