chore: fix

This commit is contained in:
2026-05-03 19:38:29 +02:00
parent 4075ae2568
commit f8473b9a54
27 changed files with 608 additions and 115 deletions
+3 -3
View File
@@ -38,7 +38,7 @@ function UserAccueil() {
return;
}
loadProducts();
}, [selectedCategory, categories]);
}, [selectedCategory, categories]); // eslint-disable-line react-hooks/exhaustive-deps
const loadProducts = async () => {
setLoading(true);
@@ -58,8 +58,8 @@ function UserAccueil() {
} else {
setProducts([]);
}
} catch (err: any) {
setError(err.message || "Erreur lors du chargement des produits");
} catch (err: unknown) {
setError(err instanceof Error ? err.message : "Erreur lors du chargement des produits");
} finally {
setLoading(false);
}
+3 -3
View File
@@ -42,7 +42,7 @@ function Cart() {
useEffect(() => {
if (!isUserAuthenticated()) { navigate("/login/client", { replace: true }); return; }
refreshCart();
}, []);
}, []); // eslint-disable-line react-hooks/exhaustive-deps
const total = cartItems.reduce((sum, item) => sum + item.price, 0);
@@ -71,7 +71,7 @@ function Cart() {
const res = await getProductById(item.product_id);
if (res.success && res.data) {
const p = res.data;
const videoMedia = p.media?.find((m: any) => m && m.type === "video");
const videoMedia = p.media?.find((m) => m && m.type === "video");
return {
...item,
image: getProductImage(p),
@@ -89,7 +89,7 @@ function Cart() {
}
};
enrich();
}, [cartItems]);
}, [cartItems]); // eslint-disable-line react-hooks/exhaustive-deps
const handleClearCart = async () => {
if (!isUserAuthenticated()) { navigate("/login/client", { replace: true }); return; }
+6 -6
View File
@@ -66,7 +66,7 @@ function Checkout() {
const res = await getProductById(item.product_id);
if (res.success && res.data) {
const p: Product = res.data;
const img = p.media?.find((m: any) => m && m.type === 'image');
const img = p.media?.find((m) => m && m.type === 'image');
if (img?.url) {
setItemImages((prev) => ({ ...prev, [item.id]: getMediaUrl(img.url) }));
}
@@ -289,7 +289,7 @@ function Checkout() {
if (response.success && response.payment_method === 'crypto') {
setCryptoPaymentData({
command_id: response.command_id!,
client_order_number: (response as any).client_order_number,
client_order_number: (response as Record<string, unknown>).client_order_number as number | undefined,
payment_status: response.payment_status!,
pay_address: response.pay_address!,
pay_amount: response.pay_amount!,
@@ -348,13 +348,13 @@ function Checkout() {
// ✅ Préparer les données pour le modal
setConfirmationData({
command_id,
client_order_number: (response as any).client_order_number,
client_order_number: (response as Record<string, unknown>).client_order_number as number | undefined,
assigned_to,
queue_info,
delivery_address: delivery_address || address,
arrivalTime,
total: frontendTotal,
referral_used: (response as any).referral_used,
referral_used: (response as Record<string, unknown>).referral_used as number | undefined,
clientInfo: {
first_name: firstName,
last_name: lastName,
@@ -369,9 +369,9 @@ function Checkout() {
} else {
setError(response.message || '❌ Erreur lors de la validation de la commande');
}
} catch (err: any) {
} catch (err: unknown) {
console.error('❌ Erreur checkout:', err);
setError(err.message || '❌ Erreur serveur. Veuillez réessayer.');
setError(err instanceof Error ? err.message : '❌ Erreur serveur. Veuillez réessayer.');
} finally {
setLoading(false);
}
@@ -65,7 +65,7 @@ function ConsultationHistorique() {
getReferralBalance().then((r) => { if (r.success) setReferralBalance(r.balance); });
}
});
}, []);
}, []); // eslint-disable-line react-hooks/exhaustive-deps
const fetchHistory = async () => {
if (!isUserAuthenticated()) { navigate('/login/client', { replace: true }); return; }
+5 -12
View File
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import { useEffect } from 'react';
import './ModalSuccess.css';
interface ModalSuccessProps {
@@ -10,20 +10,13 @@ interface ModalSuccessProps {
}
export function ModalSuccess({ isOpen, productName, quantity, price, onClose }: ModalSuccessProps) {
const [isVisible, setIsVisible] = useState(isOpen);
useEffect(() => {
setIsVisible(isOpen);
if (isOpen) {
const timer = setTimeout(() => {
setIsVisible(false);
onClose();
}, 2500);
return () => clearTimeout(timer);
}
if (!isOpen) return;
const timer = setTimeout(() => { onClose(); }, 2500);
return () => clearTimeout(timer);
}, [isOpen, onClose]);
if (!isVisible) return null;
if (!isOpen) return null;
return (
<div className="modal2-success-overlay">
@@ -104,7 +104,7 @@ function OrderDetails() {
if (commandId) {
fetchOrderDetails(commandId);
}
}, [orderId]);
}, [orderId]); // eslint-disable-line react-hooks/exhaustive-deps
// ============================================
// FONCTIONS POUR PHOTOS ET VIDÉOS (COMME PRODUCTCARD)
@@ -299,7 +299,7 @@ function OrderDetails() {
// ✅ Produits depuis items (command_items)
products:
apiData.items?.map((item: any) => ({
apiData.items?.map((item: Record<string, unknown>) => ({
id: item.id,
product_id: item.product_id,
name_product: item.produit,
@@ -63,7 +63,7 @@ function ProductDetail() {
useEffect(() => {
if (id) loadProduct(Number(id));
}, [id]);
}, [id]); // eslint-disable-line react-hooks/exhaustive-deps
const loadProduct = async (productId: number) => {
// ✅ Vérifier l'auth avant de charger le produit
@@ -110,8 +110,8 @@ function ProductDetail() {
} else {
setError(response.message || "Produit non trouvé");
}
} catch (err: any) {
setError(err.message || "Erreur lors du chargement du produit");
} catch (err: unknown) {
setError(err instanceof Error ? err.message : "Erreur lors du chargement du produit");
} finally {
setLoading(false);
}
+4 -9
View File
@@ -23,9 +23,9 @@ export default function ProfilePage() {
const [loadingProfile, setLoadingProfile] = useState(true);
// Données locales (localStorage)
const [defaultAddress, setDefaultAddress] = useState('');
const [defaultPhone, setDefaultPhone] = useState('');
const [signalPseudo, setSignalPseudo] = useState('');
const [defaultAddress, setDefaultAddress] = useState(() => localStorage.getItem(STORAGE_ADDRESS) ?? '');
const [defaultPhone, setDefaultPhone] = useState(() => localStorage.getItem(STORAGE_PHONE) ?? '');
const [signalPseudo, setSignalPseudo] = useState(() => localStorage.getItem(STORAGE_SIGNAL) ?? '');
// Feedback
const [savingContact, setSavingContact] = useState(false);
@@ -47,11 +47,6 @@ export default function ProfilePage() {
navigate('/login/client', { replace: true });
return;
}
// Charger depuis localStorage
setDefaultAddress(localStorage.getItem(STORAGE_ADDRESS) ?? '');
setDefaultPhone(localStorage.getItem(STORAGE_PHONE) ?? '');
setSignalPseudo(localStorage.getItem(STORAGE_SIGNAL) || username);
// Statut Telegram
getTelegramStatus().then((s) => { setTgLinked(s.linked); setTgEnabled(s.enabled); });
@@ -68,7 +63,7 @@ export default function ProfilePage() {
}
setLoadingProfile(false);
});
}, [navigate]);
}, [navigate]); // eslint-disable-line react-hooks/exhaustive-deps
const showSuccess = (msg: string) => {
setSuccessMsg(msg);
+21 -18
View File
@@ -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 =