diff --git a/frontend/src/pages/TimeClockPage.jsx b/frontend/src/pages/TimeClockPage.jsx index f3fc682..cd74f67 100644 --- a/frontend/src/pages/TimeClockPage.jsx +++ b/frontend/src/pages/TimeClockPage.jsx @@ -120,8 +120,15 @@ const TimeClockPage = () => { }; const stopScanner = () => { - qrControlsRef.current?.stop(); + const controls = qrControlsRef.current; qrControlsRef.current = null; + + try { + controls?.stop(); + } catch (stopError) { + console.warn('Arrêt du lecteur QR déjà effectué.', stopError); + } + if (scanFrameRef.current) { cancelAnimationFrame(scanFrameRef.current); scanFrameRef.current = null; @@ -156,7 +163,11 @@ const TimeClockPage = () => { ); if (cancelled) { - controls.stop(); + try { + controls.stop(); + } catch (stopError) { + console.warn('Arrêt du lecteur QR déjà effectué.', stopError); + } } else { qrControlsRef.current = controls; } @@ -173,7 +184,11 @@ const TimeClockPage = () => { return () => { cancelled = true; - reader.reset(); + try { + reader.reset(); + } catch (resetError) { + console.warn('Réinitialisation du lecteur QR ignorée.', resetError); + } }; }, [isScanning]);