From 178d34bc4549bce0ed827036d6b64a5708823bb8 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Tue, 26 May 2026 11:30:12 +0200 Subject: [PATCH] refactor(ui): remove excel export buttons --- src/App.tsx | 61 ++------------------------------------- src/components/TopBar.tsx | 39 ++----------------------- 2 files changed, 5 insertions(+), 95 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 162fe35..951af33 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -10,7 +10,7 @@ import { TopBar } from './components/TopBar'; import { ProductDescriptions } from './components/ProductDescriptions'; import { MatrixView } from './components/MatrixView'; import { EditPanel } from './components/EditPanel'; -import { getAllSyncedRows, saveRowToSupabase, resetAllPendingRows, saveHistoryEntry, deleteHistoryEntry, getHistoryDataForMerge } from './lib/supabase'; +import { getAllSyncedRows, saveRowToSupabase, saveHistoryEntry, deleteHistoryEntry, getHistoryDataForMerge } from './lib/supabase'; import { getStoredSession, signOut, type AuthSession } from './lib/auth'; import { LoginPage } from './components/LoginPage'; import { DimensionsView } from './components/DimensionsView'; @@ -23,7 +23,7 @@ import { MissingDataView } from './components/MissingDataView'; import { CosmeticItemsView } from './components/CosmeticItemsView'; import { ControlDashboardView } from './components/ControlDashboardView'; import { UserManagementView } from './components/UserManagementView'; -import { downloadBusinessCentralItemsExcel, previewBusinessCentralSync, applyBusinessCentralSync, isPreviewTokenMismatchError } from './services/businessCentral'; +import { previewBusinessCentralSync, applyBusinessCentralSync, isPreviewTokenMismatchError } from './services/businessCentral'; import { ControlTabId, type DashboardDrilldownRequest } from './lib/controlDashboard'; const FORCED_ZERO_STOCK_SKUS = new Set([ @@ -109,7 +109,6 @@ export default function App() { const [bcSyncQueue, setBcSyncQueue] = useState(() => readStoredBcSyncQueue()); const [isSavingAll, setIsSavingAll] = useState(false); const [isSyncingBC, setIsSyncingBC] = useState(false); - const [isDownloadingBCExcel, setIsDownloadingBCExcel] = useState(false); const [refreshTrigger, setRefreshTrigger] = useState(0); const [dashboardDrilldown, setDashboardDrilldown] = useState(null); @@ -507,43 +506,6 @@ export default function App() { reader.readAsBinaryString(file); }; - const handleExport = () => { - if (appState.data.length === 0) return; - - const wsData = [ - appState.headers, - ...appState.data.map(row => { - const copy = [...row]; - delete copy[COLUMNS.VERIFIED_DIMS]; - return copy.slice(0, appState.headers.length); - }) - ]; - const ws = XLSX.utils.aoa_to_sheet(wsData); - const wb = XLSX.utils.book_new(); - XLSX.utils.book_append_sheet(wb, ws, 'Products'); - - const dateStr = new Date().toISOString().split('T')[0]; - XLSX.writeFile(wb, `CRAZE_Products_Updated_${dateStr}.xlsx`); - - // 3. Post-export: Reset pending statuses in Supabase (pending → edited to preserve on reload) - console.log('Resetting pending statuses in Supabase...'); - resetAllPendingRows().then(success => { - if (success) { - console.log('Successfully reset all pending statuses'); - // Only clear 'pending' statuses locally; keep 'edited'/'saved' so they remain visible - setRowStatuses((prev: Record) => { - const next: Record = {}; - for (const [id, status] of Object.entries(prev)) { - if (status !== 'pending') next[id] = status as string; - } - return next; - }); - } - }); - - setAppState(prev => ({ ...prev, hasUnsavedChanges: false })); - }; - const handleSaveRow = (rowIndex: number, updatedRow: ExcelRow) => { const articleNo = String(updatedRow[COLUMNS.ARTICLE_NO]); const currentPending = pendingRows[articleNo]; @@ -915,18 +877,6 @@ export default function App() { } }; - const handleDownloadBCExcel = async () => { - setIsDownloadingBCExcel(true); - try { - const result = await downloadBusinessCentralItemsExcel(); - if (!result.success) { - alert(`Failed to download Business Central Excel:\n\n${result.error || 'Unknown error'}`); - } - } finally { - setIsDownloadingBCExcel(false); - } - }; - const captureState = (message: string) => { setUndoHistory(prev => { const newState = { @@ -1009,14 +959,10 @@ export default function App() {
{!isMaximized && ( - { setRefreshTrigger(t => t + 1); }} - hasData={appState.data.length > 0} - hasUnsavedChanges={appState.hasUnsavedChanges} userEmail={session.user.email} onSignOut={handleSignOut} canUndo={undoHistory.length > 0} @@ -1036,7 +982,6 @@ export default function App() { onSyncSelectedBcSync={handleSyncSelectedBcSync} onDiscardSelectedBcQueue={handleDiscardSelectedBcQueue} isSyncingBC={isSyncingBC} - isDownloadingBCExcel={isDownloadingBCExcel} isMaximized={isMaximized} onToggleMaximize={() => setIsMaximized(true)} /> diff --git a/src/components/TopBar.tsx b/src/components/TopBar.tsx index 115fe16..7db8943 100644 --- a/src/components/TopBar.tsx +++ b/src/components/TopBar.tsx @@ -1,15 +1,11 @@ import React, { useState, useRef, useEffect } from 'react'; -import { Download, LogOut, Undo2, CloudUpload, Loader2, ChevronDown, RotateCcw, Maximize2, X, CloudDownload } from 'lucide-react'; +import { LogOut, Undo2, CloudUpload, Loader2, ChevronDown, RotateCcw, Maximize2, X } from 'lucide-react'; import { cn } from '../lib/utils'; interface TopBarProps { stats: any; activeModule?: string; - onExport: () => void; - onDownloadBCExcel: () => void; onRefresh?: () => void; - hasData: boolean; - hasUnsavedChanges: boolean; userEmail?: string; onSignOut?: () => void; canUndo: boolean; @@ -29,12 +25,11 @@ interface TopBarProps { onSyncSelectedBcSync: () => Promise; onDiscardSelectedBcQueue: () => void; isSyncingBC: boolean; - isDownloadingBCExcel: boolean; isMaximized: boolean; onToggleMaximize: () => void; } -export function TopBar({ stats, activeModule, onExport, onDownloadBCExcel, onRefresh, hasData, hasUnsavedChanges, userEmail, onSignOut, canUndo, onUndo, undoMessage, undoSteps, pendingCount, pendingChanges, onSaveAll, onRevertRow, isSavingAll, bcQueueCount, bcQueueEntries, onToggleBcQueueSelection, onSelectAllBcQueue, onPreviewSelectedBcSync, onSyncSelectedBcSync, onDiscardSelectedBcQueue, isSyncingBC, isDownloadingBCExcel, isMaximized, onToggleMaximize }: TopBarProps) { +export function TopBar({ stats, activeModule, onRefresh, userEmail, onSignOut, canUndo, onUndo, undoMessage, undoSteps, pendingCount, pendingChanges, onSaveAll, onRevertRow, isSavingAll, bcQueueCount, bcQueueEntries, onToggleBcQueueSelection, onSelectAllBcQueue, onPreviewSelectedBcSync, onSyncSelectedBcSync, onDiscardSelectedBcQueue, isSyncingBC, isMaximized, onToggleMaximize }: TopBarProps) { const [showPending, setShowPending] = useState(false); const [showBcQueue, setShowBcQueue] = useState(false); const pendingDropdownRef = useRef(null); @@ -293,36 +288,6 @@ export function TopBar({ stats, activeModule, onExport, onDownloadBCExcel, onRef )}
- {hasData && ( - - )} - - - {onRefresh && (