import { useState } from "react"; import { motion } from "framer-motion"; import BoxContainer from "./components/BoxContainer"; import VideoWrapper from "@/components/VideoWrapper.tsx"; import ResultContainer from "@/components/ResultContainer.tsx"; import DarkVideoWrapper from "@/components/DarkVideoWrapper.tsx"; export type fetchResult = "Valid" | "Not Valid" | "Fetching" | "Error"; enum StepType { takeId, verifyId, takeFrontPic, verifyProfile, result, } const stepsArray: StepType[] = [ StepType.takeId, StepType.verifyId, StepType.takeFrontPic, StepType.verifyProfile, StepType.result, ]; export default function VerificationScene() { const [currentStep, setCurrentStep] = useState(StepType.takeId); const [idCardPicture, setIdCardPicture] = useState(); const [profilePicture, setProfilePicture] = useState(); const handleNextStep = () => { if (currentStep === StepType.result) return; setCurrentStep((currentStep + 1) % stepsArray.length); }; const handlePrevStep = () => { if (currentStep === StepType.takeId) return; setCurrentStep((currentStep - 1) % stepsArray.length); }; const sendImageToServer = async ( idCard: string, profileImage: string, setLoading: (n: fetchResult) => void, ) => { try { const response = await fetch("https://0.0.0.0:7860/uploadids", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ idCard: idCard, profileImage: profileImage }), }); if (!response.ok) { throw new Error("Erreur lors de l'envoi de l'image"); } const data = await response.json(); console.log("Image envoyée avec succès:", data); setLoading(data.message === "Valid" ? "Valid" : "Not Valid"); } catch (error) { console.error("Erreur:", error); setLoading("Error"); } }; // Animation settings for Framer Motion const animationProps = { initial: { opacity: 0, y: 50 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -50 }, transition: { duration: 0.5 }, }; let stepContent = undefined; if (currentStep === StepType.takeId) { stepContent = (

Take a picture of the Capture the front side of your ID Card

); } if (currentStep === StepType.verifyId) { stepContent = (
captured

Is This Picture Correct?

); } if (currentStep === StepType.takeFrontPic) { stepContent = (

Center your face

); } if (currentStep === StepType.verifyProfile) { stepContent = (
captured

Is This Picture Correct?

); } if (currentStep === StepType.result) { stepContent = ( ); } return ( <>
{stepContent}
); }