mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 14:35:23 +02:00
refactor(ui): remove excel export buttons
This commit is contained in:
+3
-58
@@ -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<BcSyncQueue>(() => 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<DashboardDrilldownRequest | null>(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<string, string>) => {
|
||||
const next: Record<string, string> = {};
|
||||
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() {
|
||||
<FilterProvider>
|
||||
<div className="h-screen bg-[#040d1a] text-slate-200 flex flex-col font-sans overflow-hidden">
|
||||
{!isMaximized && (
|
||||
<TopBar
|
||||
<TopBar
|
||||
stats={stats}
|
||||
activeModule={activeModule}
|
||||
onExport={handleExport}
|
||||
onDownloadBCExcel={handleDownloadBCExcel}
|
||||
onRefresh={() => { 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)}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user