This commit is contained in:
Louis Mazin 2026-09-15 19:35:10 +02:00
parent 0451ed3205
commit b54bbd018a
2 changed files with 43 additions and 15 deletions

View File

@ -136,6 +136,47 @@ const TimeClockPage = () => {
useEffect(() => () => stopScanner(), []);
useEffect(() => {
if (!isScanning || !videoRef.current) return undefined;
let cancelled = false;
const reader = new BrowserQRCodeReader();
const startReader = async () => {
try {
const controls = await reader.decodeFromConstraints(
{ video: { facingMode: { ideal: 'environment' } }, audio: false },
videoRef.current,
(result) => {
if (result && !cancelled) {
setScanResult(result.getText());
stopScanner();
}
},
);
if (cancelled) {
controls.stop();
} else {
qrControlsRef.current = controls;
}
} catch (scannerError) {
if (!cancelled) {
setError('Impossible d’accéder à la caméra. Vérifiez les permissions et utilisez HTTPS sur le réseau.');
console.error(scannerError);
stopScanner();
}
}
};
startReader();
return () => {
cancelled = true;
reader.reset();
};
}, [isScanning]);
const startScanner = async () => {
setError('');
setScanResult('');
@ -152,17 +193,6 @@ const TimeClockPage = () => {
}
setIsScanning(true);
const reader = new BrowserQRCodeReader();
qrControlsRef.current = await reader.decodeFromConstraints(
{ video: { facingMode: { ideal: 'environment' } }, audio: false },
videoRef.current,
(result) => {
if (result) {
setScanResult(result.getText());
stopScanner();
}
},
);
} catch (scannerError) {
setError('Impossible d’accéder à la caméra. Vérifiez les permissions et utilisez HTTPS sur le réseau.');
console.error(scannerError);

View File

@ -49,10 +49,8 @@ BACKEND_PID=$!
cd /home/container/frontend
if [ ! -x "node_modules/.bin/vite" ]; then
echo "node_modules absent → installation npm..."
npm ci
fi
echo "Installation des dépendances frontend..."
npm ci
echo "Build React..."