chore: fix
This commit is contained in:
@@ -27,6 +27,7 @@ import Navbar from "../../components/Navbar";
|
||||
import Toast from "../../components/Toast";
|
||||
import "./SuiviLivraison.css";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import type { IconDefinition } from "@fortawesome/fontawesome-svg-core";
|
||||
import {
|
||||
faHourglassHalf,
|
||||
faTruck,
|
||||
@@ -109,7 +110,7 @@ const getDeliveryAddress = (order: OrderWithTracking): string => {
|
||||
return order.delivery_address || order.adresse || "Non disponible";
|
||||
};
|
||||
|
||||
const formatOrderItem = (item: any) => {
|
||||
const formatOrderItem = (item: Record<string, unknown>) => {
|
||||
return {
|
||||
name:
|
||||
item.produit || item.product_name || item.name_product || "Produit",
|
||||
@@ -153,8 +154,8 @@ const getStatusLabel = (status: string): string => {
|
||||
return statusMap[status?.toLowerCase()] || "Statut inconnu";
|
||||
};
|
||||
|
||||
const getStatusIcon = (status: string): any => {
|
||||
const iconMap: Record<string, any> = {
|
||||
const getStatusIcon = (status: string): IconDefinition => {
|
||||
const iconMap: Record<string, IconDefinition> = {
|
||||
pending: faHourglassHalf,
|
||||
assigned: faBiking,
|
||||
en_route: faTruck,
|
||||
@@ -178,7 +179,7 @@ const calculateOrderPoints = (
|
||||
points: number;
|
||||
category: string;
|
||||
categoryDisplay: string;
|
||||
categoryIcon: any;
|
||||
categoryIcon: IconDefinition;
|
||||
categoryColor: string;
|
||||
} => {
|
||||
// Totaux indexés par pool (+ index spécial pour "gros&semi" exclu des points)
|
||||
@@ -186,7 +187,7 @@ const calculateOrderPoints = (
|
||||
let excludedTotal = 0;
|
||||
|
||||
if (order.items && order.items.length > 0) {
|
||||
order.items.forEach((item: any) => {
|
||||
order.items.forEach((item: Record<string, unknown>) => {
|
||||
const cat = (item.category || "").toLowerCase();
|
||||
const itemPrice = item.prix || item.price || 0;
|
||||
|
||||
@@ -332,7 +333,7 @@ function SuiviLivraison() {
|
||||
loadOrders();
|
||||
const interval = setInterval(loadOrders, 10000);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const loadOrders = async () => {
|
||||
// ✅ Vérifier l'auth avant de charger les commandes
|
||||
@@ -359,7 +360,7 @@ function SuiviLivraison() {
|
||||
|
||||
try {
|
||||
tracking = await getOrderTracking(order.id);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
console.warn(
|
||||
`Tracking non disponible pour commande ${order.id}`,
|
||||
);
|
||||
@@ -368,7 +369,7 @@ function SuiviLivraison() {
|
||||
|
||||
try {
|
||||
eta = await getOrderETA(order.id);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
console.warn(
|
||||
`ETA non disponible pour commande ${order.id}`,
|
||||
);
|
||||
@@ -389,10 +390,11 @@ function SuiviLivraison() {
|
||||
setError("Impossible de charger les commandes");
|
||||
showToast("Impossible de charger les commandes", "error");
|
||||
}
|
||||
} catch (err: any) {
|
||||
} catch (err: unknown) {
|
||||
console.error("Erreur loadOrders:", err);
|
||||
setError(err.message || "Erreur lors du chargement");
|
||||
showToast(err.message || "Erreur lors du chargement", "error");
|
||||
const msg = err instanceof Error ? err.message : "Erreur lors du chargement";
|
||||
setError(msg);
|
||||
showToast(msg, "error");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -462,7 +464,7 @@ function SuiviLivraison() {
|
||||
const pointsEarned =
|
||||
response.points_earned || selectedOrderPoints;
|
||||
const apiCategory =
|
||||
response.category || (response as any).data?.category || "";
|
||||
response.category || (response as Record<string, unknown> & { data?: { category?: string } }).data?.category || "";
|
||||
|
||||
const displayCategory =
|
||||
apiCategory && apiCategory !== "total"
|
||||
@@ -483,9 +485,10 @@ function SuiviLivraison() {
|
||||
);
|
||||
setConfirming(null);
|
||||
}
|
||||
} catch (err: any) {
|
||||
setError(err.message || "Erreur serveur");
|
||||
showToast(err.message || "Erreur serveur", "error");
|
||||
} catch (err: unknown) {
|
||||
const msg = err instanceof Error ? err.message : "Erreur serveur";
|
||||
setError(msg);
|
||||
showToast(msg, "error");
|
||||
setConfirming(null);
|
||||
}
|
||||
};
|
||||
@@ -567,9 +570,9 @@ function SuiviLivraison() {
|
||||
"error",
|
||||
);
|
||||
}
|
||||
} catch (error: any) {
|
||||
} catch (error: unknown) {
|
||||
console.error("❌ [CANCEL] Erreur:", error);
|
||||
showToast(error.message || "Erreur lors de l'annulation", "error");
|
||||
showToast(error instanceof Error ? error.message : "Erreur lors de l'annulation", "error");
|
||||
} finally {
|
||||
setCancellingOrder(null);
|
||||
}
|
||||
@@ -895,7 +898,7 @@ function SuiviLivraison() {
|
||||
<div className="items-list">
|
||||
{order.items.map(
|
||||
(
|
||||
item: any,
|
||||
item: Record<string, unknown>,
|
||||
idx: number,
|
||||
) => {
|
||||
const formatted =
|
||||
|
||||
Reference in New Issue
Block a user