This commit is contained in:
Somdev Das 2025-01-31 11:27:48 +05:30
parent 083a234bb7
commit 834fac76b9

View File

@ -98,16 +98,12 @@
// export default Search; // export default Search;
import React, { useRef, useEffect } from "react";
import React, { useRef, useEffect, useState } from "react";
import "./Search.css"; // Import CSS for styling import "./Search.css"; // Import CSS for styling
const Search: React.FC = () => { const Search: React.FC = () => {
const videoRef = useRef<HTMLVideoElement>(null); const videoRef = useRef<HTMLVideoElement>(null);
const canvasRef = useRef<HTMLCanvasElement>(null); const canvasRef = useRef<HTMLCanvasElement>(null);
const [uploadedFile, setUploadedFile] = useState<File | null>(null);
// Automatically opennig the camera when the component mounts
useEffect(() => { useEffect(() => {
const openCamera = async () => { const openCamera = async () => {
try { try {
@ -149,7 +145,6 @@ const Search: React.FC = () => {
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => { const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const file = event.target.files?.[0]; const file = event.target.files?.[0];
if (file) { if (file) {
setUploadedFile(file); // Storing the uploaded file in state
callApi(file); // Calling the API with the uploaded file callApi(file); // Calling the API with the uploaded file
} }
}; };
@ -219,5 +214,4 @@ const Search: React.FC = () => {
); );
}; };
export default Search; export default Search;