'use client' import { useState, useEffect } from 'react' import Link from 'next/link' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Progress } from '@/components/ui/progress' import { Check, Circle, PartyPopper, Rocket, X, FileUp, ArrowRight, UserPlus, Receipt, ArrowLeftRight, } from 'lucide-react' import { cn } from '@/lib/utils' interface ChecklistItem { id: string label: string description: string href: string completed: boolean icon: React.ElementType } interface NewUserChecklistProps { hasCustomers: boolean hasInvoices: boolean hasBankConnected: boolean hasSIEImport: boolean onDismiss?: () => void className?: string } const CHECKLIST_DISMISSED_KEY = 'erp_checklist_dismissed' const FRESH_START_KEY = 'erp_onboarding_fresh' export default function NewUserChecklist({ hasCustomers, hasInvoices, hasBankConnected, onDismiss, className, }: NewUserChecklistProps) { const [isDismissed, setIsDismissed] = useState(true) const [isAnimatingOut, setIsAnimatingOut] = useState(false) const [showChecklist, setShowChecklist] = useState(false) useEffect(() => { const dismissed = localStorage.getItem(CHECKLIST_DISMISSED_KEY) setIsDismissed(dismissed === 'true') const freshStart = localStorage.getItem(FRESH_START_KEY) if (freshStart === 'true') { setShowChecklist(true) } }, []) const handleFreshStart = () => { setShowChecklist(true) localStorage.setItem(FRESH_START_KEY, 'true') } const handleDismiss = () => { setIsAnimatingOut(true) setTimeout(() => { localStorage.setItem(CHECKLIST_DISMISSED_KEY, 'true') setIsDismissed(true) onDismiss?.() }, 300) } const items: ChecklistItem[] = [ { id: 'customer', label: 'Lägg till din första kund', description: 'Spara kunduppgifter för enkel fakturering', href: '/customers/new', completed: hasCustomers, icon: UserPlus, }, { id: 'invoice', label: 'Skicka din första faktura', description: 'Skapa en professionell faktura på 60 sekunder', href: '/invoices/new', completed: hasInvoices, icon: Receipt, }, { id: 'bank', label: 'Importera transaktioner', description: 'Koppla bank eller ladda upp kontoutdrag', href: '/import', completed: hasBankConnected, icon: ArrowLeftRight, }, ] const completedCount = items.filter((item) => item.completed).length const progress = (completedCount / items.length) * 100 const allCompleted = completedCount === items.length if (isDismissed) { return null } // Celebration state when all checklist items done if (showChecklist && allCompleted && !isAnimatingOut) { return (

Snyggt jobbat!

Du har slutfört alla steg. Nu är du redo att köra!

) } // Path selection — shown initially if (!showChecklist) { return (
Välkommen till gnubok

Hur vill du komma igång?

{/* Migration path — routes directly to import/migration wizard */}

Migrera från annat system

Flytta bokföring, kunder, leverantörer och fakturor från Fortnox, Visma, Bokio, Björn Lundén eller Briox

{/* Fresh start path */}
) } // Fresh start checklist return (
Kom igång

{completedCount} av {items.length} steg klara

) }