Skip to content

Commit d0ab94c

Browse files
CopilotAdamJ
andauthored
Add user notification of successful archive (#45)
* Initial plan * Add toast notifications for archive success and failure Co-authored-by: AdamJ <[email protected]>
1 parent 8525b61 commit d0ab94c

File tree

2 files changed

+15
-26
lines changed

2 files changed

+15
-26
lines changed

package-lock.json

Lines changed: 1 addition & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/contexts/TimeTrackingContext.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { useAuth } from "@/hooks/useAuth";
1212
import { createDataService, DataService } from "@/services/dataService";
1313
import { useRealtimeSync } from "@/hooks/useRealtimeSync";
1414
import { generateDailySummary } from "@/utils/timeUtil";
15+
import { toast } from "@/hooks/use-toast";
1516

1617
export interface Task {
1718
id: string;
@@ -642,7 +643,12 @@ export const TimeTrackingProvider: React.FC<{ children: React.ReactNode }> = ({
642643
});
643644
console.log('✅ Cleared current day state saved');
644645

645-
// TODO: Add user notification of successful archive
646+
// Show success notification to user
647+
toast({
648+
title: "Day Archived Successfully",
649+
description: `${dayRecord.tasks.length} task(s) archived for ${dayRecord.date}`,
650+
duration: 5000
651+
});
646652

647653
} catch (error) {
648654
console.error('❌ CRITICAL ERROR saving archived day:', error);
@@ -669,9 +675,13 @@ export const TimeTrackingProvider: React.FC<{ children: React.ReactNode }> = ({
669675

670676
console.log('🔄 Restored current day state after failed archive');
671677

672-
// TODO: Show user error notification
673-
// This should display a toast/alert to the user about the archive failure
674-
alert(`Failed to archive day data: ${error.message}\n\nYour current day has been restored. Please try archiving again.`);
678+
// Show error notification to user
679+
toast({
680+
title: "Archive Failed",
681+
description: `Failed to archive day data: ${error instanceof Error ? error.message : 'Unknown error'}. Your current day has been restored. Please try archiving again.`,
682+
variant: "destructive",
683+
duration: 7000
684+
});
675685
}
676686
}
677687
};

0 commit comments

Comments
 (0)