mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-16 11:46:21 +02:00
Improve calendar display stability and data handling
Add robust error handling and data validation to the calendar component and API routes to prevent production crashes, specifically addressing issues with invalid publicity data and ensuring array types for fetched data. Replit-Commit-Author: Agent Replit-Commit-Session-Id: b163d4c0-de5e-4f4e-a9c0-aed4c7049718 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/b163d4c0-de5e-4f4e-a9c0-aed4c7049718/FL119j1
This commit is contained in:
1 parent
d276021d3b
commit
e46922bd56
3 files changed
+94
-68
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { useState } from "react";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { ChevronLeft, ChevronRight, Plus, RefreshCw } from "lucide-react";
|
||||
import { ChevronLeft, ChevronRight, Plus, RefreshCw, Calendar as CalendarIcon } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import CalendarGrid from "@/components/CalendarGrid";
|
||||
import QuickCreateMenu from "@/components/modals/QuickCreateMenu";
|
||||
@@ -65,6 +65,12 @@ export default function Calendar() {
|
||||
|
||||
const data = await response.json();
|
||||
console.log('📅 Calendar orders received:', Array.isArray(data) ? data.length : 'NOT_ARRAY', 'items');
|
||||
|
||||
// Protection contre les données invalides en production
|
||||
if (!Array.isArray(data)) {
|
||||
console.warn('⚠️ Orders data is not an array, returning empty array');
|
||||
return [];
|
||||
}
|
||||
return data;
|
||||
},
|
||||
});
|
||||
@@ -101,6 +107,12 @@ export default function Calendar() {
|
||||
|
||||
const data = await response.json();
|
||||
console.log('📅 Calendar deliveries received:', Array.isArray(data) ? data.length : 'NOT_ARRAY', 'items');
|
||||
|
||||
// Protection contre les données invalides en production
|
||||
if (!Array.isArray(data)) {
|
||||
console.warn('⚠️ Deliveries data is not an array, returning empty array');
|
||||
return [];
|
||||
}
|
||||
return data;
|
||||
},
|
||||
});
|
||||
@@ -183,7 +195,7 @@ export default function Calendar() {
|
||||
<div className="bg-white shadow-sm border-b border-gray-200 p-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center">
|
||||
<Calendar className="w-8 h-8 text-blue-600 mr-3" />
|
||||
<CalendarIcon className="w-8 h-8 text-blue-600 mr-3" />
|
||||
<div>
|
||||
<h2 className="text-2xl font-bold text-gray-900">
|
||||
Calendrier des Commandes & Livraisons
|
||||
@@ -259,9 +271,9 @@ export default function Calendar() {
|
||||
) : (
|
||||
<CalendarGrid
|
||||
currentDate={currentDate}
|
||||
orders={orders}
|
||||
deliveries={deliveries}
|
||||
publicities={publicities}
|
||||
orders={orders || []}
|
||||
deliveries={deliveries || []}
|
||||
publicities={publicities || []}
|
||||
selectedStoreId={selectedStoreId}
|
||||
userGroups={user?.userGroups || []}
|
||||
onDateClick={handleDateClick}
|
||||
|
||||
Reference in new issue
Block a user