'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, Sparkles, X, } from 'lucide-react' import { cn } from '@/lib/utils' interface ChecklistItem { id: string label: string description: string href: string completed: boolean } interface NewUserChecklistProps { hasCustomers: boolean hasInvoices: boolean hasBankConnected: boolean hasReceipts: boolean onDismiss?: () => void className?: string } const CHECKLIST_DISMISSED_KEY = 'erp_checklist_dismissed' export default function NewUserChecklist({ hasCustomers, hasInvoices, hasBankConnected, hasReceipts, onDismiss, className, }: NewUserChecklistProps) { const [isDismissed, setIsDismissed] = useState(true) // Start hidden until we check localStorage const [isAnimatingOut, setIsAnimatingOut] = useState(false) useEffect(() => { // Check if checklist has been dismissed const dismissed = localStorage.getItem(CHECKLIST_DISMISSED_KEY) setIsDismissed(dismissed === 'true') }, []) const items: ChecklistItem[] = [ { id: 'account', label: 'Skapa konto', description: 'Du har ett konto!', href: '#', completed: true, // Always completed if they're seeing this }, { id: 'customer', label: 'Lägg till din första kund', description: 'Spara kunduppgifter för enkel fakturering', href: '/customers/new', completed: hasCustomers, }, { id: 'invoice', label: 'Skicka din första faktura', description: 'Skapa en professionell faktura på 60 sekunder', href: '/invoices/new', completed: hasInvoices, }, { id: 'bank', label: 'Importera transaktioner', description: 'Importera kontoutdrag från din bank', href: '/import', completed: hasBankConnected, }, { id: 'receipt', label: 'Skanna ditt första kvitto', description: 'Fotografera för automatisk bokföring', href: '/receipts/scan', completed: hasReceipts, }, ] const completedCount = items.filter((item) => item.completed).length const progress = (completedCount / items.length) * 100 const allCompleted = completedCount === items.length const handleDismiss = () => { setIsAnimatingOut(true) setTimeout(() => { localStorage.setItem(CHECKLIST_DISMISSED_KEY, 'true') setIsDismissed(true) onDismiss?.() }, 300) } // Don't show if dismissed or all completed if (isDismissed) { return null } // Auto-dismiss after all completed with celebration if (allCompleted && !isAnimatingOut) { return ( Snyggt jobbat! Du har slutfört alla steg. Nu är du redo att köra! ) } return ( Kom igång {completedCount} av {items.length} steg klara Stäng checklista {items.map((item) => ( {item.completed ? ( {item.label} ) : ( {item.label} {item.description} )} ))} ) }
Snyggt jobbat!
Du har slutfört alla steg. Nu är du redo att köra!
{completedCount} av {items.length} steg klara
{item.label}
{item.description}