'use client'; import { useEffect, useState } from 'react'; import Link from 'next/link'; import { useAuth } from '@/lib/hooks/useAuth'; import { MessageSquare, Mail, Users, Zap, CheckCircle2, ArrowUpRight, Settings, Sparkles, Rocket } from 'lucide-react'; interface SetupStatus { smsConfigured: boolean; emailConfigured: boolean; contactsImported: boolean; campaignsSetup: boolean; } export default function SetupPage() { const { user } = useAuth(); const [progress, setProgress] = useState({ smsConfigured: false, emailConfigured: false, contactsImported: false, campaignsSetup: false, }); const [loading, setLoading] = useState(true); useEffect(() => { fetch('/api/v1/onboarding/status') .then(res => res.json()) .then(data => { if (data.setupStatus) { setProgress(data.setupStatus); } }) .catch(() => {}) .finally(() => setLoading(false)); }, []); const steps = [ { key: 'smsConfigured', label: 'Configure SMS', description: 'Set up two-way texting with A2P registration to communicate with your contacts via SMS.', done: progress.smsConfigured, href: '/settings/sms', icon: MessageSquare, color: 'purple' }, { key: 'emailConfigured', label: 'Set up Email', description: 'Connect your email account and configure domain authentication for better deliverability.', done: progress.emailConfigured, href: '/settings/email', icon: Mail, color: 'orange' }, { key: 'contactsImported', label: 'Import Contacts', description: 'Bring in your existing database of contacts to start managing relationships.', done: progress.contactsImported, href: '/contacts', icon: Users, color: 'blue' }, { key: 'campaignsSetup', label: 'Create Campaigns', description: 'Set up automated follow-up campaigns to nurture your leads and stay top of mind.', done: progress.campaignsSetup, href: '/automations', icon: Zap, color: 'emerald' }, ]; const completedCount = steps.filter(s => s.done).length; const progressPercent = (completedCount / steps.length) * 100; const isComplete = progressPercent === 100; const colorClasses: Record = { purple: { bg: 'bg-purple-100', icon: 'text-purple-600', border: 'border-purple-200' }, orange: { bg: 'bg-orange-100', icon: 'text-orange-600', border: 'border-orange-200' }, blue: { bg: 'bg-blue-100', icon: 'text-blue-600', border: 'border-blue-200' }, emerald: { bg: 'bg-emerald-100', icon: 'text-emerald-600', border: 'border-emerald-200' }, }; return (
{/* Header */}
{isComplete ? ( ) : ( )}

{isComplete ? 'Setup Complete!' : 'Setup Your Account'}

{isComplete ? `Great job${user?.firstName ? `, ${user.firstName}` : ''}! You're ready to make the most of CRESync.` : `Complete these steps to unlock all features${user?.firstName ? `, ${user.firstName}` : ''}.`}

{/* Progress Overview */}
{isComplete ? ( ) : ( )}

Progress Overview

{completedCount} of {steps.length} steps completed

{Math.round(progressPercent)}% complete
{/* Progress Bar */}
{steps.map((step, index) => (
{step.done ? ( ) : ( )} {step.label.split(' ')[0]}
))}
{/* Setup Steps */}

Setup Steps

Complete each step to get the most out of CRESync

{loading ? (
{[1, 2, 3, 4].map((i) => (
))}
) : (
{steps.map((step, index) => { const StepIcon = step.icon; const colors = colorClasses[step.color]; return (
{/* Step Number & Icon */}
{step.done ? ( ) : ( index + 1 )}
{/* Content */}

{step.label}

{step.description}

{/* Action */}
{step.done ? ( Completed ) : ( Get Started )}
); })}
)}
{/* Completion Message */} {isComplete && (

You're All Set!

Your account is fully configured. Start managing your contacts, running campaigns, and closing more deals.

Go to Dashboard
)}
); }