From 3a2455f918c086e66533b35db26610a671e66d18 Mon Sep 17 00:00:00 2001 From: N3WT DE COMPET Date: Sat, 31 May 2025 09:21:09 +0200 Subject: [PATCH] chore: On ne fait pas disparaitre les notifications en "erreur" --- Front-End/src/components/FlashNotification.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Front-End/src/components/FlashNotification.js b/Front-End/src/components/FlashNotification.js index c706780..04775c0 100644 --- a/Front-End/src/components/FlashNotification.js +++ b/Front-End/src/components/FlashNotification.js @@ -33,12 +33,19 @@ export default function FlashNotification({ const [isVisible, setIsVisible] = useState(true); useEffect(() => { - const timer = setTimeout(() => { - setIsVisible(false); // Déclenche la disparition - setTimeout(onClose, 300); // Appelle onClose après l'animation - }, displayPeriod); // Notification visible pendant 3 secondes par défaut - return () => clearTimeout(timer); - }, [onClose, displayPeriod]); + setIsVisible(true); + }, [message, type, errorCode, onClose]); + + useEffect(() => { + if (type !== 'error') { + const timer = setTimeout(() => { + setIsVisible(false); // Déclenche la disparition + setTimeout(onClose, 300); // Appelle onClose après l'animation + }, displayPeriod); + return () => clearTimeout(timer); + } + // Pour les erreurs, pas de timeout : la notification reste affichée + }, [onClose, displayPeriod, type]); if (!message || !isVisible) return null;