From fbbe1375ab8595f082bb02a5525de2f64b92e409 Mon Sep 17 00:00:00 2001
From: michaelschal <35957947-michaelschal@users.noreply.replit.com>
Date: Fri, 11 Jul 2025 16:55:20 +0000
Subject: [PATCH] Improve photo capture reliability and address camera access
issues
Adds enhanced camera setup, error handling, and canvas drawing in `useCamera.tsx`, `CameraModal.tsx`, and `NewSaleForm.tsx`.
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: dec54137-d5a2-4406-8ad4-5f2f9fb110bf
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/e6a2493b-9ed8-4bd8-be32-29049cc60fa3.jpg
---
client/src/components/CameraModal.tsx | 35 ++++++++-
client/src/components/NewSaleForm.tsx | 4 +
client/src/hooks/useCamera.tsx | 106 ++++++++++++++++++++------
3 files changed, 119 insertions(+), 26 deletions(-)
diff --git a/client/src/components/CameraModal.tsx b/client/src/components/CameraModal.tsx
index 066874d..87075ca 100644
--- a/client/src/components/CameraModal.tsx
+++ b/client/src/components/CameraModal.tsx
@@ -26,7 +26,31 @@ export default function CameraModal({
useEffect(() => {
if (isOpen && videoRef.current) {
// Ensure video starts playing when modal opens
- videoRef.current.play().catch(console.error);
+ const video = videoRef.current;
+
+ const handleLoadedMetadata = () => {
+ console.log('Video loaded metadata:', video.videoWidth, 'x', video.videoHeight);
+ };
+
+ const handleCanPlay = () => {
+ console.log('Video can play');
+ };
+
+ const handleError = (error: Event) => {
+ console.error('Video error:', error);
+ };
+
+ video.addEventListener('loadedmetadata', handleLoadedMetadata);
+ video.addEventListener('canplay', handleCanPlay);
+ video.addEventListener('error', handleError);
+
+ video.play().catch(console.error);
+
+ return () => {
+ video.removeEventListener('loadedmetadata', handleLoadedMetadata);
+ video.removeEventListener('canplay', handleCanPlay);
+ video.removeEventListener('error', handleError);
+ };
}
}, [isOpen, videoRef]);
@@ -57,10 +81,13 @@ export default function CameraModal({
{/* Overlay pour aider à cadrer la pièce d'identité */}
-
-
+
+
Cadrez la pièce d'identité dans le rectangle
+
+ {photoType === 'recto' ? 'RECTO' : 'VERSO'}
+
@@ -72,7 +99,7 @@ export default function CameraModal({