1 Commits

View File

@@ -594,6 +594,7 @@ const downloadExpediente = async (pedimentoId, pedimentoName, setSuccess, showMe
const fileCount = uploadType === 'folders' ? filesToUpload.length : selectedFiles.length; const fileCount = uploadType === 'folders' ? filesToUpload.length : selectedFiles.length;
showMessage(`Subiendo ${fileCount} archivo(s)...`, 'info'); showMessage(`Subiendo ${fileCount} archivo(s)...`, 'info');
let alertMessage = '';
const uploadEndpoint = `${API_URL}/customs/pedimentos/bulk-create/`; const uploadEndpoint = `${API_URL}/customs/pedimentos/bulk-create/`;
const result = await postFormDataWithAuth(uploadEndpoint, formData); const result = await postFormDataWithAuth(uploadEndpoint, formData);
@@ -610,10 +611,38 @@ const downloadExpediente = async (pedimentoId, pedimentoName, setSuccess, showMe
} }
showMessage(errorMsg, 'error'); showMessage(errorMsg, 'error');
}else{ }else{
showMessage( const data = await result.json();
`${result.uploaded_count || fileCount} archivo(s) subido(s) exitosamente`, console.log(data);
'success' if(data.already_existing_count > 0){
); // Crear una cadena con todos los pedimentos
const existingList = data.already_existing
.map(pedimento => `${pedimento.pedimento_app}`)
.join('\n');
showMessage(
`${data.message}\n\nPedimentos ya existentes:\n${existingList}`,
'warning'
);
}
else if(data.failed_files && data.failed_files.length > 0) {
// Sección de archivos fallidos
alertMessage += `ARCHIVOS CON ERRORES (${data.failed_files.length}):\n`;
data.failed_files.forEach((file, index) => {
alertMessage += `\n${index + 1}. ${file.archivo_original}`;
alertMessage += `\n Error: ${file.error}`;
});
showMessage(
`${alertMessage}`,
'warning'
);
}
else{
showMessage(
`${result.uploaded_count || fileCount} archivo(s) subido(s) exitosamente`,
'success'
);
}
} }
// showMessage( // showMessage(