mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 14:45:24 +02:00
feat: remove vendor CSV upload button from data modal
All vendor files are linked via Dropbox, making manual upload unnecessary. Removes the Upload Vendor CSV button, handleVendorUpload handler, and processVendorCSV import. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
98ba0d1708
commit
32a7de8aea
@@ -5,7 +5,7 @@ import Dashboard from './components/Dashboard';
|
|||||||
import FilterBar from './components/FilterBar';
|
import FilterBar from './components/FilterBar';
|
||||||
import AIChat from './components/AIChat';
|
import AIChat from './components/AIChat';
|
||||||
import CrazeLogo from './components/CrazeLogo';
|
import CrazeLogo from './components/CrazeLogo';
|
||||||
import { processCSV, processExcel, filterData, aggregateData, processAdsCSV, processAdsExcel, mergeSalesAndAdsData, processTrafficExcel, processStockExcel, filterAdsData, calculateForecastViewData, processVendorStockExcel, processUKInventoryExcel, calculateVelocityMap, getUniqueValues, processForecastExcel, processBuyBoxExcel, processVendorCSV, processBSRExcel, filterBsrData } from './services/dataProcessor';
|
import { processCSV, processExcel, filterData, aggregateData, processAdsCSV, processAdsExcel, mergeSalesAndAdsData, processTrafficExcel, processStockExcel, filterAdsData, calculateForecastViewData, processVendorStockExcel, processUKInventoryExcel, calculateVelocityMap, getUniqueValues, processForecastExcel, processBuyBoxExcel, processBSRExcel, filterBsrData } from './services/dataProcessor';
|
||||||
import { SalesRecord, FilterState, AggregatedData, AdsRecord, TrafficRecord, ForecastRecord, ProductForecastData, ActiveExperiment, BSRRecord } from './types';
|
import { SalesRecord, FilterState, AggregatedData, AdsRecord, TrafficRecord, ForecastRecord, ProductForecastData, ActiveExperiment, BSRRecord } from './types';
|
||||||
import { queryGemini } from './services/geminiService';
|
import { queryGemini } from './services/geminiService';
|
||||||
import { ChartIcon, TableIcon, UploadIcon, DownloadIcon, CloseIcon, TrendingIcon, MegaphoneIcon } from './components/Icons';
|
import { ChartIcon, TableIcon, UploadIcon, DownloadIcon, CloseIcon, TrendingIcon, MegaphoneIcon } from './components/Icons';
|
||||||
@@ -480,46 +480,6 @@ const App: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Handle uploaded Vendor CSV (sends to Supabase via API with batching)
|
// Handle uploaded Vendor CSV (sends to Supabase via API with batching)
|
||||||
const handleVendorUpload = async (file: File) => {
|
|
||||||
setSyncing(true);
|
|
||||||
try {
|
|
||||||
console.log("[App] Parsing Vendor CSV on client...");
|
|
||||||
const rows = await processVendorCSV(file);
|
|
||||||
|
|
||||||
if (rows.length === 0) {
|
|
||||||
alert("No valid rows found in CSV.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`[App] Uploading ${rows.length} rows in batches...`);
|
|
||||||
|
|
||||||
const BATCH_SIZE = 500;
|
|
||||||
let totalUpserted = 0;
|
|
||||||
|
|
||||||
for (let i = 0; i < rows.length; i += BATCH_SIZE) {
|
|
||||||
const batch = rows.slice(i, i + BATCH_SIZE);
|
|
||||||
const response = await fetch('/api/upload-vendor-data', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify(batch),
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await response.json();
|
|
||||||
if (!response.ok) throw new Error(result.error || `Batch ${i / BATCH_SIZE + 1} failed`);
|
|
||||||
|
|
||||||
totalUpserted += result.rowsUpserted;
|
|
||||||
console.log(`[App] Batch ${Math.floor(i / BATCH_SIZE) + 1} complete. Total: ${totalUpserted}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
alert(`Vendor data uploaded: ${totalUpserted} rows processed successfully.`);
|
|
||||||
setIsDataModalOpen(false);
|
|
||||||
} catch (error: any) {
|
|
||||||
console.error("Failed to upload vendor data", error);
|
|
||||||
alert(`Error uploading vendor data: ${error.message}`);
|
|
||||||
} finally {
|
|
||||||
setSyncing(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 2. Schedule Auto-Refresh (Background)
|
// 2. Schedule Auto-Refresh (Background)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -1029,7 +989,6 @@ const App: React.FC = () => {
|
|||||||
onSalesUpload={handleSalesUpload}
|
onSalesUpload={handleSalesUpload}
|
||||||
onAdsUpload={handleAdsUpload}
|
onAdsUpload={handleAdsUpload}
|
||||||
onTrafficUpload={handleTrafficUpload}
|
onTrafficUpload={handleTrafficUpload}
|
||||||
onVendorUpload={handleVendorUpload}
|
|
||||||
onUrlSubmit={handleDataFetch}
|
onUrlSubmit={handleDataFetch}
|
||||||
isLoading={syncing}
|
isLoading={syncing}
|
||||||
activeUrl={activeUrl}
|
activeUrl={activeUrl}
|
||||||
|
|||||||
Reference in New Issue
Block a user