Skip to content

Commit 1aa2128

Browse files
Improve stop all clockings UX
Fix dashboard stop-all button by guarding tenant and active entries, add no-active-clockings toast, and ensure data reload after stopping. X-Lovable-Edit-ID: edt-89576224-febc-4c09-9b2a-033d2dd23539
2 parents e06e44a + 57c31b9 commit 1aa2128

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/pages/admin/Dashboard.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,18 @@ export default function Dashboard() {
467467
};
468468

469469
const handleStopAllClockings = async () => {
470-
if (!profile?.tenant_id) return;
470+
if (!profile?.tenant_id) {
471+
console.error("No tenant ID available");
472+
return;
473+
}
474+
475+
if (activeWork.length === 0) {
476+
toast({
477+
title: t("dashboard.noActiveClockings", "No active clockings"),
478+
description: t("dashboard.noActiveClockingsDescription", "There are no active time entries to stop."),
479+
});
480+
return;
481+
}
471482

472483
setStoppingAll(true);
473484
try {
@@ -476,8 +487,9 @@ export default function Dashboard() {
476487
title: t("dashboard.allClockingsStopped"),
477488
description: t("dashboard.allClockingsStoppedDescription", { count: stoppedCount }),
478489
});
479-
loadData();
490+
await loadData();
480491
} catch (error: any) {
492+
console.error("Failed to stop all clockings:", error);
481493
toast({
482494
variant: "destructive",
483495
title: t("dashboard.stopAllFailed"),

0 commit comments

Comments
 (0)