Implement basic camera feature to allow users to capture identity photos

Replaces `useCamera` with `useSimpleCamera` and introduces `SimpleCameraModal` for capturing photos.

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/9ada347d-ab83-40f0-9a0e-5fa4d829189e.jpg
This commit is contained in:
michaelschal committed 2025-07-11 18:02:54 +00:00
1 parent 97c6f3ec1e
commit a6a188e68f
3 files changed
+248 -24

No files matched your search

+6 -24
View File
@@ -9,12 +9,12 @@ import { Alert, AlertDescription } from '@/components/ui/alert';
import { useToast } from '@/hooks/use-toast';
import { useAuth } from '@/hooks/useAuth';
import { useStoreContext } from '@/hooks/useStoreContext';
import { useCamera } from '@/hooks/useCamera';
import { useSimpleCamera } from '@/hooks/useSimpleCamera';
import { useCameraTest } from '@/hooks/useCameraTest';
import { apiRequest } from '@/lib/queryClient';
import { validateRequiredFields, validateEAN13, ARTICLE_CATEGORY_MAPPING, IDENTITY_TYPES, PAYMENT_METHODS } from '@/lib/validation';
import { Package, User, Users, Save, Calendar, BadgeCheck, Info, Camera, TestTube, Upload, Trash2 } from 'lucide-react';
import CameraModal from '@/components/CameraModal';
import SimpleCameraModal from '@/components/SimpleCameraModal';
import type { PhotoType } from '@/types/sale';
interface FormData {
@@ -54,7 +54,7 @@ export default function NewSaleForm() {
startCamera,
capturePhoto,
stopCamera
} = useCamera();
} = useSimpleCamera();
// Camera test functionality
const { testResults, runCameraTest } = useCameraTest();
@@ -216,27 +216,9 @@ export default function NewSaleForm() {
description: "Préparation de la caméra en cours...",
});
// Démarrer la caméra
// Démarrer la caméra simple
await startCamera(photoType);
console.log('Camera started successfully');
// Attendre 2 secondes supplémentaires pour s'assurer que la vidéo est prête
console.log('Waiting for video to be fully ready...');
await new Promise(resolve => setTimeout(resolve, 2000));
// Vérifier l'état final de la vidéo
if (videoRef.current) {
const video = videoRef.current;
console.log('Final video state check:', {
videoWidth: video.videoWidth,
videoHeight: video.videoHeight,
readyState: video.readyState,
paused: video.paused,
currentTime: video.currentTime
});
}
console.log('Camera should be ready for capture');
console.log('Simple camera started successfully');
} catch (error) {
console.error('Camera start failed:', error);
@@ -770,7 +752,7 @@ export default function NewSaleForm() {
</div>
{/* Camera Modal */}
<CameraModal
<SimpleCameraModal
isOpen={isCameraOpen}
photoType={currentPhotoType}
videoRef={videoRef}