diff --git a/attached_assets/Pasted--ordersCount-32-deliveriesCount-37-pendingOrdersCount-24-averageDelivery-1757343526354_1757343526354.txt b/attached_assets/Pasted--ordersCount-32-deliveriesCount-37-pendingOrdersCount-24-averageDelivery-1757343526354_1757343526354.txt new file mode 100644 index 0000000..d1376e4 --- /dev/null +++ b/attached_assets/Pasted--ordersCount-32-deliveriesCount-37-pendingOrdersCount-24-averageDelivery-1757343526354_1757343526354.txt @@ -0,0 +1,201 @@ + + ordersCount: 32, + + deliveriesCount: 37, + + pendingOrdersCount: 24, + + averageDeliveryTime: '5.7272727272727275 jours (commande → livraison, livraisons avec commande liée uniquement)', + + totalPalettes: 3009, + + totalPackages: 11 + +} + +📋 PUBLICITIES RETURNED: { count: 29 } + +GET /api/stats/monthly 304 in 571ms + +GET /api/publicities 304 in 60ms + +🔍 [PRODUCTION] Raw messages from DB: 2 items: [ + + { + + id: 16, + + title: 'Mise à jour Prix', + + content: 'Merci de mettre vos prix a jour tous les matins, certain magasin ne le font pas.', + + type: 'success', + + storeId: null, + + createdBy: 'admin', + + createdAt: 2025-08-18T10:45:08.585Z + + }, + + { + + id: 8, + + title: 'Bon de Livraison', + + content: 'Lorsque vous rentrez un numéro de bon de livraison, faite le a l identique, même les majuscules. Pour My candy Shop, prendre le numéro de commande.', + + type: 'info', + + storeId: null, + + createdBy: 'admin_local', + + createdAt: 2025-08-07T11:04:38.123Z + + } + +] + +🔍 [PRODUCTION] Looking for user with username: admin + +🔍 [PRODUCTION] Looking for user with username: admin_local + +🔍 [PRODUCTION] User search result: Not found + +❌ [PRODUCTION] User not found with username: admin_local + +🔍 [PRODUCTION] User search result: Found + +🎯 [PRODUCTION] Found announcements: 2 + +GET /api/announcements 304 in 97ms + +GET /api/user 304 in 11ms + +Deliveries API called with: { + + startDate: undefined, + + endDate: undefined, + + storeId: '1', + + withBL: undefined, + + userRole: 'admin' + +} + +🔍 Admin deliveries filtering by store: { storeId: '1', groupIds: [ 1 ], role: 'admin' } + +Fetching all deliveries + +Orders API called with: { + + startDate: undefined, + + endDate: undefined, + + storeId: '1', + + userRole: 'admin' + +} + +🔍 Admin orders filtering by store: { storeId: '1', groupIds: [ 1 ], role: 'admin' } + +Fetching all orders + +📢 [SERVER] Fetching announcements for user: admin_local environment: production + +📢 [SERVER] User found: { username: 'admin', role: 'admin' } + +🎯 [PRODUCTION] Using PostgreSQL DASHBOARD_MESSAGES table + +🔍 [PRODUCTION] Raw messages from DB: 2 items: [ + + { + + id: 16, + + title: 'Mise à jour Prix', + + content: 'Merci de mettre vos prix a jour tous les matins, certain magasin ne le font pas.', + + type: 'success', + + storeId: null, + + createdBy: 'admin', + + createdAt: 2025-08-18T10:45:08.585Z + + }, + + { + + id: 8, + + title: 'Bon de Livraison', + + content: 'Lorsque vous rentrez un numéro de bon de livraison, faite le a l identique, même les majuscules. Pour My candy Shop, prendre le numéro de commande.', + + type: 'info', + + storeId: null, + + createdBy: 'admin_local', + + createdAt: 2025-08-07T11:04:38.123Z + + } + +] + +🔍 [PRODUCTION] Looking for user with username: admin + +🔍 [PRODUCTION] Looking for user with username: admin_local + +Customer Orders API called with: { groupIds: [ 1 ], userRole: 'admin' } + +🔍 [PRODUCTION] User search result: Found + +🔍 [PRODUCTION] User search result: Not found + +❌ [PRODUCTION] User not found with username: admin_local + +🎯 [PRODUCTION] Found announcements: 2 + +GET /api/announcements 304 in 18ms + +Customer Orders returned: 11 items + +GET /api/customer-orders 304 in 25ms + +🔗 PRODUCTION: getDeliveries() récupéré 82 livraisons avec relations + +Deliveries returned: 82 items + +GET /api/deliveries 304 in 161ms + +GET /api/groups 304 in 103ms + +🔗 PRODUCTION: getOrders() récupéré 64 commandes avec relations + +Orders returned: 64 items + +GET /api/orders 304 in 217ms + +GET /api/user 304 in 5ms + +🔍 Avoirs API called with: { groupIds: undefined, userRole: 'admin' } + +GET /api/suppliers 304 in 8ms + +📋 Avoirs returned: 1 items + +GET /api/avoirs 304 in 14ms + diff --git a/attached_assets/{EE654853-B061-44D5-B2E9-8448DE342BFF}_1757343513626.png b/attached_assets/{EE654853-B061-44D5-B2E9-8448DE342BFF}_1757343513626.png new file mode 100644 index 0000000..4476958 Binary files /dev/null and b/attached_assets/{EE654853-B061-44D5-B2E9-8448DE342BFF}_1757343513626.png differ diff --git a/debug_client_error.js b/debug_client_error.js new file mode 100644 index 0000000..88ca2f0 --- /dev/null +++ b/debug_client_error.js @@ -0,0 +1,45 @@ +// 🔍 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'); \ No newline at end of file diff --git a/sql/fix_table_production.sql b/sql/fix_table_production.sql new file mode 100644 index 0000000..9a238f2 --- /dev/null +++ b/sql/fix_table_production.sql @@ -0,0 +1,44 @@ +-- 🔧 CORRECTION TABLE PRODUCTION +-- Script pour corriger la table avoirs en production + +-- 1. Vérifier la structure actuelle +SELECT 'STRUCTURE_ACTUELLE' as check_type, + column_name, + data_type, + is_nullable, + column_default +FROM information_schema.columns +WHERE table_name = 'avoirs' +ORDER BY ordinal_position; + +-- 2. Corriger les colonnes pour les rendre optionnelles +ALTER TABLE avoirs ALTER COLUMN invoice_reference DROP NOT NULL; +ALTER TABLE avoirs ALTER COLUMN amount DROP NOT NULL; + +-- 3. Vérifier après correction +SELECT 'STRUCTURE_CORRIGÉE' as check_type, + column_name, + data_type, + is_nullable, + column_default +FROM information_schema.columns +WHERE table_name = 'avoirs' +ORDER BY ordinal_position; + +-- 4. Test d'insertion avec champs optionnels +INSERT INTO avoirs ( + supplier_id, + group_id, + comment, + commercial_processed, + created_by +) VALUES ( + (SELECT id FROM suppliers LIMIT 1), + (SELECT id FROM groups LIMIT 1), + 'Test champs optionnels', + false, + (SELECT id FROM users LIMIT 1)::varchar +) RETURNING id, invoice_reference, amount; + +-- 5. Nettoyer le test +DELETE FROM avoirs WHERE comment = 'Test champs optionnels'; \ No newline at end of file