* feat: import system improvements, INK2 fix, and Swedish text corrections - SIE parser: Windows-1252 and CP437 encoding detection and decoding - Bank file parser: add Nordea Business (Företag) CSV format - Bank file parser: improve format detection for SEB, Länsförsäkringar, generic CSV - INK2 engine: calculate årets resultat (7222) from income statement for open fiscal years - Dashboard: parallel Supabase queries, simplified dashboard page - Fix Swedish characters (å, ä, ö) in BAS data descriptions, validation messages, AI consent disclosures - Import wizard UI improvements across all steps - Migration: add 'bas_range' match type to sie_account_mappings constraint - Extensive new tests for SIE parser encoding and bank file parser Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: arcim migration wizard UX fixes, Sentry setup, and extension scaffolding Arcim migration wizard improvements: - Progress bar now excludes non-interactive steps (migrating/result) - Fix OAuth text to match target="_blank" behavior (new tab, not redirect) - Display month names instead of "Månad X" in preview - Fix Swedish typo "förifylla" in no-company-info message - Replace native checkboxes with shadcn Switch in options step - Add ConfirmationDialog before starting migration - Show progress percentage during migration - Add "Nästa steg" guidance and navigation links in result step - Add "Försök igen" button in error state (returns to options) - Add Bokio company ID help text (GUID from URL) - Add Fortnox integration add-on hint on connection failure Also includes: SIE import system improvements, INK2 fixes, Swedish text corrections, Sentry error tracking setup, and arcim-migration extension scaffolding. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address PR review feedback - Fix OAuth error recovery blank page (restore provider from URL params) - Pass real userId to MigrationWizard instead of empty string - Remove ~50 debug console.log statements from sie-import.ts - Fix comment referencing account 3740 → 3741 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
189 lines
5.6 KiB
TypeScript
189 lines
5.6 KiB
TypeScript
'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
|
|
onDismiss?: () => void
|
|
className?: string
|
|
}
|
|
|
|
const CHECKLIST_DISMISSED_KEY = 'erp_checklist_dismissed'
|
|
|
|
export default function NewUserChecklist({
|
|
hasCustomers,
|
|
hasInvoices,
|
|
hasBankConnected,
|
|
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,
|
|
},
|
|
]
|
|
|
|
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 (
|
|
<Card className={cn('border-success/50 bg-success/5', className)}>
|
|
<CardContent className="pt-6">
|
|
<div className="flex items-center gap-4">
|
|
<div className="p-3 rounded-full bg-success/10">
|
|
<Sparkles className="h-6 w-6 text-success" />
|
|
</div>
|
|
<div className="flex-1">
|
|
<p className="font-medium text-success">Snyggt jobbat!</p>
|
|
<p className="text-sm text-muted-foreground">
|
|
Du har slutfört alla steg. Nu är du redo att köra!
|
|
</p>
|
|
</div>
|
|
<Button variant="ghost" size="sm" onClick={handleDismiss}>
|
|
<X className="h-4 w-4" />
|
|
</Button>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Card
|
|
className={cn(
|
|
'transition-all duration-300',
|
|
isAnimatingOut && 'opacity-0 scale-95',
|
|
className
|
|
)}
|
|
>
|
|
<CardHeader className="pb-3">
|
|
<div className="flex items-center justify-between">
|
|
<div>
|
|
<CardTitle className="text-base">Kom igång</CardTitle>
|
|
<p className="text-sm text-muted-foreground">
|
|
{completedCount} av {items.length} steg klara
|
|
</p>
|
|
</div>
|
|
<Button
|
|
variant="ghost"
|
|
size="icon"
|
|
className="h-8 w-8 text-muted-foreground"
|
|
onClick={handleDismiss}
|
|
>
|
|
<X className="h-4 w-4" />
|
|
<span className="sr-only">Stäng checklista</span>
|
|
</Button>
|
|
</div>
|
|
<Progress value={progress} className="h-1.5 mt-3" />
|
|
</CardHeader>
|
|
<CardContent className="pt-0">
|
|
<ul className="space-y-1">
|
|
{items.map((item) => (
|
|
<li key={item.id}>
|
|
{item.completed ? (
|
|
<div className="flex items-center gap-3 p-2 rounded-lg">
|
|
<div className="p-1 rounded-full bg-success/10">
|
|
<Check className="h-3.5 w-3.5 text-success" />
|
|
</div>
|
|
<span className="text-sm text-muted-foreground line-through">
|
|
{item.label}
|
|
</span>
|
|
</div>
|
|
) : (
|
|
<Link
|
|
href={item.href}
|
|
className="group flex items-center gap-3 p-2 rounded-lg hover:bg-secondary/50 transition-colors"
|
|
>
|
|
<div className="p-1 rounded-full border border-border">
|
|
<Circle className="h-3.5 w-3.5 text-muted-foreground" />
|
|
</div>
|
|
<div className="flex-1 min-w-0">
|
|
<p className="text-sm font-medium group-hover:text-primary transition-colors">
|
|
{item.label}
|
|
</p>
|
|
<p className="text-xs text-muted-foreground truncate">
|
|
{item.description}
|
|
</p>
|
|
</div>
|
|
</Link>
|
|
)}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</CardContent>
|
|
</Card>
|
|
)
|
|
}
|