import React, { useState, useEffect } from 'react'; import { Box, Typography, Chip, Button, CircularProgress, Tooltip } from '@mui/material'; import { PlayArrow, Pause, Stop } from '@mui/icons-material'; import { ShimmerHeader } from './styled'; import { DashboardHeaderProps } from './types'; const DashboardHeader: React.FC = ({ title, subtitle, statusChips = [], rightContent, customIcon, workflowControls }) => { // State for enhanced start button behavior const [isFirstVisit, setIsFirstVisit] = useState(false); const [showFloatingCTA, setShowFloatingCTA] = useState(false); const [tooltipMessage, setTooltipMessage] = useState("🎯 Start your daily content workflow here!"); // Check if this is first visit and set up enhanced behavior useEffect(() => { const hasVisited = localStorage.getItem('alwrity-has-visited'); if (!hasVisited) { setIsFirstVisit(true); localStorage.setItem('alwrity-has-visited', 'true'); // Set up floating CTA after 15 seconds const timer = setTimeout(() => { setShowFloatingCTA(true); // Auto-hide after 30 seconds setTimeout(() => setShowFloatingCTA(false), 30000); }, 15000); return () => clearTimeout(timer); } }, []); // Progressive tooltip messages useEffect(() => { if (!isFirstVisit) return; const messages = [ "🎯 Start your daily content workflow here!", "💡 This button launches your personalized content plan", "⚡ Click to begin your digital marketing automation" ]; let messageIndex = 0; const interval = setInterval(() => { messageIndex = (messageIndex + 1) % messages.length; setTooltipMessage(messages[messageIndex]); }, 10000); // Change message every 10 seconds return () => clearInterval(interval); }, [isFirstVisit]); return ( {customIcon && ( )} {title} {subtitle && ( {subtitle} )} {/* Workflow Controls */} {workflowControls && ( {/* Workflow Control Buttons */} {!workflowControls.isWorkflowActive ? ( /* Enhanced Start Button with Phase 1 Improvements */ {`${workflowControls.completedTasks}/${workflowControls.totalTasks}`} {/* Floating CTA for first-time users */} {showFloatingCTA && isFirstVisit && ( 🎯 Ready to create amazing content? Click the orange button above to start your personalized content workflow! )} ) : ( /* In-Progress/Completed Controls with Enhanced Styling */ {/* In-Progress/Completed Status with Lightning Glow */} {`${workflowControls.completedTasks}/${workflowControls.totalTasks}`} )} )} {statusChips.length > 0 && ( {statusChips.map((chip, index) => ( ))} )} {rightContent} ); }; export default DashboardHeader;