import React, { useEffect, useState } from 'react';
import { createPortal } from 'react-dom';
import { FaCheckCircle, FaTimesCircle, FaInfoCircle, FaPodcast, FaMusic } from 'react-icons/fa';
import './WorkflowToast.css';
// The actual Toast component
const Toast = ({ message, type = 'success', onClose }) => {
const [visible, setVisible] = useState(false);
useEffect(() => {
// Add class to body to prevent scrollbar
document.body.classList.add('has-toast');
// Show toast immediately
setVisible(true);
// Hide toast after delay
const timer = setTimeout(() => {
setVisible(false);
// Delay actual removal from DOM to allow exit animation to complete
setTimeout(() => {
document.body.classList.remove('has-toast');
onClose();
}, 300);
}, 5000); // Extended duration for toast visibility
return () => {
clearTimeout(timer);
document.body.classList.remove('has-toast');
};
}, [onClose, message]);
const getIcon = () => {
// Check if message is related to podcast generation
const isPodcastMessage = message.toLowerCase().includes('podcast') ||
message.toLowerCase().includes('play') ||
message.toLowerCase().includes('listen');
switch (type) {
case 'success':
return isPodcastMessage ?