import React, { useState, useEffect } from "react"; import { ShoppingCart } from "lucide-react"; interface LoadingModalProps { isOpen: boolean; title: string; message: string; } const LoadingModal: React.FC = ({ isOpen, title, message, }) => { const [isAnimating, setIsAnimating] = useState(false); const [shouldRender, setShouldRender] = useState(false); console.log("🔄 [LOADING_MODAL] Renderizando - isOpen:", isOpen); useEffect(() => { if (isOpen) { setShouldRender(true); // Pequeno delay para garantir que o DOM está pronto antes de iniciar a animação setTimeout(() => setIsAnimating(true), 10); } else { // Iniciar animação de saída setIsAnimating(false); // Remover do DOM após a animação terminar const timer = setTimeout(() => setShouldRender(false), 300); return () => clearTimeout(timer); } }, [isOpen]); // Não renderizar se não deve estar visível if (!shouldRender) { console.log("🔄 [LOADING_MODAL] Modal não está aberto, retornando null"); return null; } console.log("🔄 [LOADING_MODAL] Renderizando modal com título:", title); return (
{/* Overlay */}
{/* Dialog */}
{/* Header */}

{title}

Carregando

{/* Content */}

{message}

); }; export default LoadingModal;