import React, { useState } from 'react'; import { OnboardingDataLegacy, GoalPrimary, LeadType, Channel, ExperienceLevel, GCIRange, CRMPainPoint, ExternalSystem } from '../types'; import { Button } from './Button'; import { ClayCard } from './ClayCard'; import { ArrowRight, Check } from 'lucide-react'; // Use legacy interface which has snake_case properties type OnboardingData = OnboardingDataLegacy; interface Props { onComplete: (data: OnboardingData) => void; } const INITIAL_DATA: OnboardingData = { // Experience questions years_in_business: null, gci_last_12_months: null, // CRM questions using_other_crm: null, current_crm_name: '', crm_pain_points: [], // Goals goals_selected: [], // Lead questions has_lead_source: null, lead_source_name: '', wants_more_leads: null, lead_type_desired: [], leads_per_month_target: '', // Channels channels_selected: [], // Systems to connect systems_to_connect: [], // Custom values for personalization user_first_name: '', user_last_name: '', user_email: '', brokerage_name: '', }; const TOTAL_STEPS = 7; export const OnboardingFlow: React.FC = ({ onComplete }) => { const [step, setStep] = useState(1); const [data, setData] = useState(INITIAL_DATA); const updateData = (key: keyof OnboardingData, value: any) => { setData(prev => ({ ...prev, [key]: value })); }; const toggleArrayItem = (key: keyof OnboardingData, item: T) => { setData(prev => { const arr = prev[key] as T[]; if (arr.includes(item)) { return { ...prev, [key]: arr.filter(i => i !== item) }; } return { ...prev, [key]: [...arr, item] }; }); }; const nextStep = () => setStep(prev => prev + 1); // Step 1: Experience Questions const renderStep1 = () => (

Tell us about your experience

This helps us personalize your setup

{Object.values(ExperienceLevel).map((level) => ( updateData('years_in_business', level)} className="flex items-center justify-between" > {level} {data.years_in_business === level && } ))}
{Object.values(GCIRange).map((range) => ( updateData('gci_last_12_months', range)} className="flex items-center justify-between" > {range} {data.gci_last_12_months === range && } ))}
); // Step 2: CRM Questions const renderStep2 = () => (

Your Current CRM

Tell us about your current setup

updateData('using_other_crm', true)} > Yes updateData('using_other_crm', false)} > No
{data.using_other_crm === true && ( <>
updateData('current_crm_name', e.target.value)} placeholder="Enter your CRM name..." className="w-full p-4 rounded-xl bg-gray-50 border-none shadow-inner focus:ring-2 focus:ring-indigo-500 outline-none" />
{['Follow Up Boss', 'KvCore', 'Salesforce', 'HubSpot', 'Other'].map(crm => ( ))}

Select all that apply

{Object.values(CRMPainPoint).map((painPoint) => ( toggleArrayItem('crm_pain_points', painPoint)} className="py-3 px-4 text-center text-sm" > {painPoint} {data.crm_pain_points.includes(painPoint) && ( )} ))}
)}
); // Step 3: Goals const renderStep3 = () => (

What are you looking to accomplish?

Select all that apply

{Object.values(GoalPrimary).map((goal) => ( toggleArrayItem('goals_selected', goal)} className="flex items-center justify-between" > {goal} {data.goals_selected.includes(goal) && } ))}
); // Step 4: Lead Source const renderStep4 = () => (

Lead Sources

Tell us about your lead generation

updateData('has_lead_source', true)} > Yes updateData('has_lead_source', false)} > No
{data.has_lead_source === true && (
updateData('lead_source_name', e.target.value)} placeholder="e.g. Zillow, Referrals, Meta..." className="w-full p-4 rounded-xl bg-gray-50 border-none shadow-inner focus:ring-2 focus:ring-indigo-500 outline-none" />
)}
updateData('wants_more_leads', true)} > Yes updateData('wants_more_leads', false)} > No
{data.wants_more_leads === true && (

Select all that apply

{[LeadType.SELLER, LeadType.BUYER, LeadType.COMMERCIAL].map((type) => ( toggleArrayItem('lead_type_desired', type)} className="py-3 px-4 text-center text-sm" > {type} {data.lead_type_desired.includes(type) && ( )} ))}
)}
); // Step 5: Systems to Connect const renderStep5 = () => (

Systems to Connect

What other systems would you like to connect?

{Object.values(ExternalSystem).map((system) => ( toggleArrayItem('systems_to_connect', system)} className="flex items-center justify-between" > {system} {data.systems_to_connect.includes(system) && } ))}
); // Step 6: Contact Channels const renderStep6 = () => (

Contact Channels

How do you want to reach leads?

{Object.values(Channel).map((channel) => ( toggleArrayItem('channels_selected', channel)} className="flex items-center justify-between" > {channel} {data.channels_selected.includes(channel) && } ))}
); // Step 7: Custom Values (Profile Info) const renderStep7 = () => { const isStep7Valid = data.user_first_name.trim() !== '' && data.user_last_name.trim() !== '' && data.user_email.trim() !== '' && data.brokerage_name.trim() !== ''; return (

Let's personalize your experience

Tell us a bit about yourself

updateData('user_first_name', e.target.value)} placeholder="Enter your first name" className="w-full p-4 rounded-xl bg-gray-50 border-none shadow-inner focus:ring-2 focus:ring-indigo-500 outline-none" />
updateData('user_last_name', e.target.value)} placeholder="Enter your last name" className="w-full p-4 rounded-xl bg-gray-50 border-none shadow-inner focus:ring-2 focus:ring-indigo-500 outline-none" />
updateData('user_email', e.target.value)} placeholder="Enter your email address" className="w-full p-4 rounded-xl bg-gray-50 border-none shadow-inner focus:ring-2 focus:ring-indigo-500 outline-none" />
updateData('brokerage_name', e.target.value)} placeholder="Enter your brokerage name" className="w-full p-4 rounded-xl bg-gray-50 border-none shadow-inner focus:ring-2 focus:ring-indigo-500 outline-none" />
); }; return (
{Array.from({ length: TOTAL_STEPS }, (_, i) => i + 1).map(s => (
))}
{step === 1 && renderStep1()} {step === 2 && renderStep2()} {step === 3 && renderStep3()} {step === 4 && renderStep4()} {step === 5 && renderStep5()} {step === 6 && renderStep6()} {step === 7 && renderStep7()}
); };