From 4ad80fa57d243b477d41c7daa0eb25dcfaa35cfd Mon Sep 17 00:00:00 2001 From: Xor290 Date: Thu, 14 May 2026 20:52:42 +0200 Subject: [PATCH] chore: fix error in suivilivraison.tsx --- frontend-prep/src/pages/User/SuiviLivraison.tsx | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/frontend-prep/src/pages/User/SuiviLivraison.tsx b/frontend-prep/src/pages/User/SuiviLivraison.tsx index e57357c3..e3b04007 100644 --- a/frontend-prep/src/pages/User/SuiviLivraison.tsx +++ b/frontend-prep/src/pages/User/SuiviLivraison.tsx @@ -336,20 +336,17 @@ function SuiviLivraison() { }, []); // eslint-disable-line react-hooks/exhaustive-deps const loadOrders = async () => { - // ✅ Vérifier l'auth avant de charger les commandes if (!isUserAuthenticated()) { - console.log("❌ [loadOrders] Non authentifié"); navigate("/login/client", { replace: true }); return; } try { - setLoading(true); const response = await getMyOrders(); - if (response.success && response.commands) { + if (response.success) { const ordersWithTracking = await Promise.all( - response.commands.map(async (order: OrderDetail) => { + (response.commands || []).map(async (order: OrderDetail) => { const normalizedOrder = { ...order, total: getTotalAmount(order), @@ -361,18 +358,12 @@ function SuiviLivraison() { try { tracking = await getOrderTracking(order.id); } catch { - console.warn( - `Tracking non disponible pour commande ${order.id}`, - ); tracking = undefined; } try { eta = await getOrderETA(order.id); } catch { - console.warn( - `ETA non disponible pour commande ${order.id}`, - ); eta = undefined; } @@ -386,9 +377,6 @@ function SuiviLivraison() { setOrders(ordersWithTracking); setError(""); - } else { - setError("Impossible de charger les commandes"); - showToast("Impossible de charger les commandes", "error"); } } catch (err: unknown) { console.error("Erreur loadOrders:", err);