import { useState, useEffect } from "react"; import ComplexAlert from "../../Components/Icons/ComplexAlert/ComplexAlert"; import "./index.css"; // Import your CSS file for toast styles const Toast = () => { const [showToast, setShowToast] = useState(false); const [progress, setProgress] = useState(100); // Start with full progress useEffect(() => { let timer; if (showToast) { timer = setTimeout(() => { setShowToast(false); }, 5000); // 5000 milliseconds = 5 seconds // Interval to update progress bar const interval = setInterval(() => { setProgress((prevProgress) => prevProgress - (100 / 5000 * 100)); // Decrease progress based on time }, 100); // Update every 100 milliseconds return () => { clearTimeout(timer); clearInterval(interval); }; } }, [showToast]); const toggleToast = () => { setShowToast(!showToast); setProgress(100); // Reset progress when showing toast }; return (