mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Add client-side debugging scripts for JavaScript errors and unhandled promise rejections to aid in troubleshooting the credits module. Correct the production database schema for the 'avoirs' table by making 'invoice_reference' and 'amount' columns nullable, and include a test insertion to verify the fix. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869/mpVybiP
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
// 🔍 DEBUG CLIENT-SIDE ERRORS
|
|
// Ajoutez ce script dans la console de votre navigateur pour capturer les erreurs
|
|
|
|
console.log('🔍 DEBUG AVOIRS - Initialisation...');
|
|
|
|
// Intercepter les erreurs React
|
|
window.addEventListener('error', (event) => {
|
|
console.error('🚨 ERREUR JAVASCRIPT:', {
|
|
message: event.message,
|
|
filename: event.filename,
|
|
lineno: event.lineno,
|
|
colno: event.colno,
|
|
error: event.error
|
|
});
|
|
});
|
|
|
|
// Intercepter les erreurs de Promise non gérées
|
|
window.addEventListener('unhandledrejection', (event) => {
|
|
console.error('🚨 ERREUR PROMISE:', {
|
|
reason: event.reason,
|
|
promise: event.promise
|
|
});
|
|
});
|
|
|
|
// Tester l'accès direct à l'API
|
|
fetch('/api/avoirs', { credentials: 'include' })
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
console.log('✅ API TEST SUCCESS:', data);
|
|
console.log('📊 Nombre d\'avoirs:', data.length);
|
|
if (data.length > 0) {
|
|
console.log('📋 Premier avoir:', data[0]);
|
|
console.log('🔍 Structure:', {
|
|
hasInvoiceReference: data[0].invoiceReference !== undefined,
|
|
hasAmount: data[0].amount !== undefined,
|
|
invoiceRefType: typeof data[0].invoiceReference,
|
|
amountType: typeof data[0].amount
|
|
});
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('❌ API TEST ERROR:', error);
|
|
});
|
|
|
|
console.log('🔍 DEBUG initialisé - surveillez les erreurs ci-dessus'); |