mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 12:35:25 +02:00
feat: manual Save All button in TopBar with pending change tracking
Changes are now queued locally (yellow highlight) and only persisted to Supabase when the user clicks the Save button in the top-right corner. The button shows the count of pending changes and a spinner while saving. EditPanel closes immediately after queuing — no Supabase call per edit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
c544b9b709
commit
acc1d06269
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Download, Database, LogOut, Undo2 } from 'lucide-react';
|
||||
import { Download, LogOut, Undo2, CloudUpload, Loader2 } from 'lucide-react';
|
||||
import { cn } from '../lib/utils';
|
||||
|
||||
interface TopBarProps {
|
||||
@@ -13,9 +13,12 @@ interface TopBarProps {
|
||||
onUndo: () => void;
|
||||
undoMessage?: string;
|
||||
undoSteps: number;
|
||||
pendingCount: number;
|
||||
onSaveAll: () => Promise<void>;
|
||||
isSavingAll: boolean;
|
||||
}
|
||||
|
||||
export function TopBar({ stats, onExport, hasData, hasUnsavedChanges, userEmail, onSignOut, canUndo, onUndo, undoMessage, undoSteps }: TopBarProps) {
|
||||
export function TopBar({ stats, onExport, hasData, hasUnsavedChanges, userEmail, onSignOut, canUndo, onUndo, undoMessage, undoSteps, pendingCount, onSaveAll, isSavingAll }: TopBarProps) {
|
||||
return (
|
||||
<header className="bg-[#020812] border-b border-slate-700/30 h-32 flex items-center justify-between px-10 shrink-0 z-10 shadow-2xl">
|
||||
<div className="flex items-center -ml-4">
|
||||
@@ -56,6 +59,16 @@ export function TopBar({ stats, onExport, hasData, hasUnsavedChanges, userEmail,
|
||||
)}
|
||||
|
||||
<div className="flex items-center gap-3">
|
||||
{pendingCount > 0 && (
|
||||
<button
|
||||
onClick={onSaveAll}
|
||||
disabled={isSavingAll}
|
||||
className="flex items-center gap-2 px-4 py-2 rounded-md text-sm font-bold transition-all bg-green-600 hover:bg-green-500 disabled:opacity-60 text-white shadow-lg shadow-green-900/30"
|
||||
>
|
||||
{isSavingAll ? <Loader2 className="w-4 h-4 animate-spin" /> : <CloudUpload className="w-4 h-4" />}
|
||||
{isSavingAll ? 'Saving...' : `Save ${pendingCount} change${pendingCount > 1 ? 's' : ''}`}
|
||||
</button>
|
||||
)}
|
||||
{hasData && (
|
||||
<button
|
||||
onClick={onExport}
|
||||
|
||||
Reference in New Issue
Block a user