'use client' import { useState } from 'react' import { useTranslations } from 'next-intl' import { Button } from '@/components/ui/button' import { Card } from '@/components/ui/card' import { Badge } from '@/components/ui/badge' import { Loader2, ArrowRight, Building2, User, Check } from 'lucide-react' import { cn } from '@/lib/utils' import type { EntityType } from '@/types' interface Step1Props { initialData: { entity_type?: EntityType } onNext: (data: { entity_type: EntityType }) => void isSaving: boolean } export default function Step1EntityType({ initialData, onNext, isSaving }: Step1Props) { const t = useTranslations('onboarding') const [selected, setSelected] = useState(initialData.entity_type) // "Enskild firma" and "Aktiebolag" are statutory legal entity types — kept // in Swedish in both locales. const entityOptions: { value: EntityType | string label: string description: string icon: typeof Building2 disabled?: boolean }[] = [ { value: 'enskild_firma', label: 'Enskild firma', description: t('step1_ef_description'), icon: User, }, { value: 'aktiebolag', label: 'Aktiebolag', description: t('step1_ab_description'), icon: Building2, }, ] const handleNext = () => { if (!selected) { const msg = 'step 1: fortsätt clicked without entity type selected' console.error('[onboarding]', msg) fetch('/api/log', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: msg }) }).catch(() => {}) return } onNext({ entity_type: selected }) } return (
{entityOptions.map((option) => { const Icon = option.icon const isSelected = selected === option.value return ( ) })}
) }