Fix incorrect error during import, better logging during import
This commit is contained in:
@@ -528,31 +528,18 @@ export function Settings() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
const data = await response.json().catch(() => ({}));
|
||||
// Only handle error if we don't have any progress yet
|
||||
if (!importProgress?.current && !purchaseOrdersProgress?.current) {
|
||||
// Only check response status if we don't have any progress
|
||||
if (!importProgress?.current && !purchaseOrdersProgress?.current) {
|
||||
if (!response.ok && response.status !== 200) {
|
||||
const data = await response.json().catch(() => ({}));
|
||||
throw new Error(data.error || 'Failed to start CSV import');
|
||||
}
|
||||
} else {
|
||||
console.log('Response not ok but import is in progress, continuing...');
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Import error:', error);
|
||||
|
||||
// If we have any progress, assume the import is still running
|
||||
if (importProgress?.current || purchaseOrdersProgress?.current) {
|
||||
console.log('Error occurred but import appears to be running');
|
||||
return;
|
||||
}
|
||||
|
||||
// Only clean up if we don't have any progress
|
||||
if (eventSource) {
|
||||
eventSource.close();
|
||||
setEventSource(null);
|
||||
}
|
||||
handleError('CSV import', error instanceof Error ? error.message : 'Unknown error');
|
||||
setIsImporting(false);
|
||||
setImportProgress(null);
|
||||
setPurchaseOrdersProgress(null);
|
||||
handleError('Data import', error instanceof Error ? error.message : 'Unknown error');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user