mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-15 03:09:32 +02:00
Fix issue where commercial processed status incorrectly retained on update
Implement Zod validation on PUT /avoirs/:id endpoint to ensure correct data handling for commercialProcessed field, defaulting it to false and logging validation errors. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869/2DtJTqh
This commit is contained in:
1 parent
4129ae68d0
commit
80b9d387c7
2 files changed
+16
-2
No files matched your search
+10
-1
@@ -2501,10 +2501,19 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
}
|
||||
}
|
||||
|
||||
const updatedAvoir = await storage.updateAvoir(id, req.body);
|
||||
// ✅ CRITICAL FIX: Validate data with Zod schema (partial)
|
||||
console.log('💰 PUT Avoir - Raw body received:', JSON.stringify(req.body, null, 2));
|
||||
const validatedData = insertAvoirSchema.partial().parse(req.body);
|
||||
console.log('💰 PUT Avoir - Validated data:', JSON.stringify(validatedData, null, 2));
|
||||
|
||||
const updatedAvoir = await storage.updateAvoir(id, validatedData);
|
||||
console.log('✅ Avoir updated:', id, 'by user:', user.id);
|
||||
res.json(updatedAvoir);
|
||||
} catch (error) {
|
||||
if (error instanceof z.ZodError) {
|
||||
console.error('❌ [PUT AVOIR] ERREURS VALIDATION ZOD:', JSON.stringify(error.errors, null, 2));
|
||||
return res.status(400).json({ message: "Validation error", errors: error.errors });
|
||||
}
|
||||
console.error("Error updating avoir:", error);
|
||||
res.status(500).json({ message: "Failed to update avoir" });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user