diff --git a/replit.md b/replit.md index 65e15e7..459d8bd 100644 --- a/replit.md +++ b/replit.md @@ -285,6 +285,9 @@ Preferred communication style: Simple, everyday language. - ✅ Photo capture system fully integrated with database storage - ✅ Modal de détails des ventes opérationnel avec support complet des photos - ✅ API et schéma de base de données synchronisés pour la production +- ✅ Bug critique corrigé : mapping camelCase/snake_case pour photo_ticket +- ✅ NewSaleForm.tsx corrigé pour inclure photoTicket dans la soumission +- ✅ API routes.ts corrigé avec mapping automatique des photos - ✅ RegisFlow prêt pour déploiement en production avec toutes les fonctionnalités ### Docker Configuration & Cleanup (January 9, 2025) diff --git a/server/routes.ts b/server/routes.ts index 41f3c2c..7f9eec5 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -243,8 +243,39 @@ export async function registerRoutes(app: Express): Promise { targetStoreId = user.storeId; } - const saleData = insertSaleSchema.parse({ + // Debug logging + console.log('=== PHOTO MAPPING DEBUG ==='); + console.log('photoRecto present:', !!req.body.photoRecto); + console.log('photoVerso present:', !!req.body.photoVerso); + console.log('photoTicket present:', !!req.body.photoTicket); + console.log('photoTicket length:', req.body.photoTicket?.length); + + // Map frontend camelCase to database snake_case for photos + const mappedBody = { ...req.body, + }; + + // Add photo fields with proper mapping, only if they exist and are not empty + if (req.body.photoRecto) { + mappedBody.photo_recto = req.body.photoRecto; + console.log('Added photo_recto to mappedBody'); + } + if (req.body.photoVerso) { + mappedBody.photo_verso = req.body.photoVerso; + console.log('Added photo_verso to mappedBody'); + } + if (req.body.photoTicket) { + mappedBody.photo_ticket = req.body.photoTicket; + console.log('Added photo_ticket to mappedBody'); + } + + // Remove camelCase versions to avoid conflicts + delete mappedBody.photoRecto; + delete mappedBody.photoVerso; + delete mappedBody.photoTicket; + + const saleData = insertSaleSchema.parse({ + ...mappedBody, storeId: targetStoreId, userId: user.id });