import React, { useMemo } from 'react'; import { OnboardingDataLegacy, SystemState, GoalPrimary, Channel, ExternalSystem } from '../types'; import { ClayCard } from './ClayCard'; import { Button } from './Button'; // Use legacy interface which has snake_case properties type OnboardingData = OnboardingDataLegacy; import { Upload, MessageSquare, Mail, Rocket, CheckCircle, Smartphone, Users, Target, BarChart3, Layers, Link2, Sparkles, BookOpen, ClipboardList } from 'lucide-react'; interface DashboardProps { onboardingData: OnboardingData; systemState: SystemState; onSetupClick: (setupType: string) => void; onQuizClick: () => void; } interface TodoItem { id: string; title: string; description: string; icon: React.ReactNode; iconBgColor: string; iconTextColor: string; setupType: string; isCompleted: boolean; } export const Dashboard: React.FC = ({ onboardingData, systemState, onSetupClick, onQuizClick }) => { const { user_first_name, goals_selected, channels_selected, systems_to_connect, has_lead_source } = onboardingData; const { sms_configured, email_configured, contacts_imported } = systemState; // Calculate setup progress const progressData = useMemo(() => { const items: { label: string; completed: boolean }[] = []; if (channels_selected.includes(Channel.SMS)) { items.push({ label: 'SMS', completed: sms_configured }); } if (channels_selected.includes(Channel.EMAIL)) { items.push({ label: 'Email', completed: email_configured }); } if (has_lead_source) { items.push({ label: 'Contacts', completed: contacts_imported }); } if (systems_to_connect.length > 0) { items.push({ label: 'Integrations', completed: false }); // Assuming integrations tracking } const completedCount = items.filter(i => i.completed).length; const percentage = items.length > 0 ? Math.round((completedCount / items.length) * 100) : 0; return { items, completedCount, percentage }; }, [channels_selected, systems_to_connect, has_lead_source, sms_configured, email_configured, contacts_imported]); // Generate subtitle based on goals const subtitle = useMemo(() => { if (goals_selected.length === 0) { return "Let's get your CRM set up!"; } const goalDescriptions: Record = { [GoalPrimary.NEW_SELLER_LEADS]: 'seller leads', [GoalPrimary.NEW_BUYER_LEADS]: 'buyer leads', [GoalPrimary.GET_ORGANIZED]: 'organization', [GoalPrimary.FOLLOW_UP_CAMPAIGNS]: 'follow-up campaigns', [GoalPrimary.TRACK_METRICS]: 'tracking metrics' }; const goalSummary = goals_selected .slice(0, 2) .map(g => goalDescriptions[g] || g) .join(' and '); return `Let's help you with ${goalSummary}${goals_selected.length > 2 ? ' and more' : ''}!`; }, [goals_selected]); // Build dynamic to-do items const todoItems: TodoItem[] = useMemo(() => { const items: TodoItem[] = []; // Goal-based to-dos if (goals_selected.includes(GoalPrimary.NEW_SELLER_LEADS)) { items.push({ id: 'seller-leads-campaign', title: 'Start campaign to get new seller leads', description: 'Launch an automated campaign targeting potential sellers in your market.', icon: , iconBgColor: 'bg-emerald-100', iconTextColor: 'text-emerald-600', setupType: 'SELLER_CAMPAIGN', isCompleted: false }); } if (goals_selected.includes(GoalPrimary.NEW_BUYER_LEADS)) { items.push({ id: 'buyer-leads-campaign', title: 'Start campaign to get new buyer leads', description: 'Reach potential buyers with targeted messaging and automation.', icon: , iconBgColor: 'bg-blue-100', iconTextColor: 'text-blue-600', setupType: 'BUYER_CAMPAIGN', isCompleted: false }); } if (goals_selected.includes(GoalPrimary.FOLLOW_UP_CAMPAIGNS)) { items.push({ id: 'follow-up-campaigns', title: 'Set up follow-up campaigns', description: 'Create automated sequences to nurture your leads over time.', icon: , iconBgColor: 'bg-violet-100', iconTextColor: 'text-violet-600', setupType: 'FOLLOW_UP_CAMPAIGN', isCompleted: false }); } if (goals_selected.includes(GoalPrimary.GET_ORGANIZED)) { items.push({ id: 'configure-pipeline', title: 'Configure pipeline stages', description: 'Customize your pipeline to match your sales process.', icon: , iconBgColor: 'bg-amber-100', iconTextColor: 'text-amber-600', setupType: 'PIPELINE_CONFIG', isCompleted: false }); } if (goals_selected.includes(GoalPrimary.TRACK_METRICS)) { items.push({ id: 'reporting-dashboard', title: 'Set up reporting dashboard', description: 'Track your key metrics and performance indicators.', icon: , iconBgColor: 'bg-rose-100', iconTextColor: 'text-rose-600', setupType: 'REPORTING_SETUP', isCompleted: false }); } // Channel-based to-dos if (channels_selected.includes(Channel.SMS) && !sms_configured) { items.push({ id: 'sms-setup', title: 'Set up SMS (A2P registration)', description: 'Configure your phone number and complete carrier registration to start texting.', icon: , iconBgColor: 'bg-purple-100', iconTextColor: 'text-purple-600', setupType: 'SMS_SETUP', isCompleted: false }); } if (channels_selected.includes(Channel.EMAIL) && !email_configured) { items.push({ id: 'email-setup', title: 'Configure email settings', description: 'Connect your domain and set up authentication for deliverability.', icon: , iconBgColor: 'bg-orange-100', iconTextColor: 'text-orange-600', setupType: 'EMAIL_SETUP', isCompleted: false }); } // Systems integration to-do if (systems_to_connect.length > 0) { const systemNames = systems_to_connect.map(s => { const names: Record = { [ExternalSystem.DIALER]: 'Dialer', [ExternalSystem.TRANSACTION_MANAGEMENT]: 'Transaction Management', [ExternalSystem.OTHER_CRM]: 'CRM', [ExternalSystem.MARKETING_PLATFORM]: 'Marketing Platform' }; return names[s] || s; }); items.push({ id: 'connect-systems', title: 'Connect your systems', description: `Integrate with ${systemNames.join(', ')} for seamless workflow.`, icon: , iconBgColor: 'bg-cyan-100', iconTextColor: 'text-cyan-600', setupType: 'INTEGRATIONS', isCompleted: false }); } // Lead upload to-do if (has_lead_source && !contacts_imported) { items.push({ id: 'upload-leads', title: 'Upload your lead list', description: 'Import your existing contacts to start automating your outreach.', icon: , iconBgColor: 'bg-teal-100', iconTextColor: 'text-teal-600', setupType: 'UPLOAD_LEADS', isCompleted: false }); } return items; }, [goals_selected, channels_selected, systems_to_connect, has_lead_source, sms_configured, email_configured, contacts_imported]); // Completed items (for showing completion status) const completedItems = useMemo(() => { const items: { id: string; label: string }[] = []; if (channels_selected.includes(Channel.SMS) && sms_configured) { items.push({ id: 'sms-done', label: 'SMS configured' }); } if (channels_selected.includes(Channel.EMAIL) && email_configured) { items.push({ id: 'email-done', label: 'Email configured' }); } if (has_lead_source && contacts_imported) { items.push({ id: 'leads-done', label: 'Leads uploaded' }); } return items; }, [channels_selected, has_lead_source, sms_configured, email_configured, contacts_imported]); return (
{/* Welcome Header */}

Welcome, {user_first_name || 'there'}!

{subtitle}

{/* Setup Progress Card */}

Setup Progress

{progressData.completedCount} of {progressData.items.length} steps completed

{progressData.percentage}%
{/* Progress indicators */}
{progressData.items.map((item, index) => (
{item.completed && } {item.label}
))}
{/* Completed Items */} {completedItems.length > 0 && (
{completedItems.map(item => (
{item.label}
))}
)} {/* Dynamic To-Do Items */}

Your To-Do List

{todoItems.length === 0 ? (
🎉

All caught up!

You've completed all your setup tasks.

) : (
{todoItems.map((item) => (
{item.icon}

{item.title}

{item.description}

))}
)}
{/* Quick Links Section */}

Quick Links

{/* Performance Quiz Card */}

Take the Performance Quiz

See how you compare to your peers

{/* Browse Resources Card */} onSetupClick('BROWSE_RESOURCES')} className="cursor-pointer hover:transform hover:-translate-y-1 transition-all duration-300" >

Browse Resources

Tutorials, guides, and best practices

); };