'use client' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' import { Skeleton } from '@/components/ui/skeleton' import { CheckCircle2, AlertTriangle, XCircle, Info } from 'lucide-react' import Link from 'next/link' import type { BokslutReadinessReport } from '@/lib/bokslut/readiness-aggregator' interface PreflightStepProps { report: BokslutReadinessReport | null isLoading: boolean error: string | null onContinue: () => void } export function PreflightStep({ report, isLoading, error, onContinue }: PreflightStepProps) { if (isLoading) { return ( ) } if (error) { return (

{error}

) } if (!report) { return null } return (
{report.period.name}

{report.period.period_start} – {report.period.period_end}

{report.ready ? ( Redo för bokslut ) : ( Inte redo )}
{report.blockers.length > 0 && ( Måste åtgärdas innan bokslut {report.blockers.map((blocker, i) => ( ))} )} {report.warnings.length > 0 && ( Varningar {report.warnings.map((warning, i) => (

{warning}

))}
)} {report.reminders.length > 0 && ( Påminnelser {report.reminders.map((reminder) => (

{reminder.message}

{reminder.href && ( Öppna )}
))}
)}
) } /** * Renders a blocker with a contextual action link when we can derive one. * Falls back to plain text otherwise. */ function BlockerRow({ blocker, report }: { blocker: string; report: BokslutReadinessReport }) { let href: string | null = null let actionLabel: string | null = null if (/draft journal entries/i.test(blocker) && report.draftCount > 0) { href = '/bookkeeping?status=draft' actionLabel = 'Visa utkast' } else if (/voucher gap/i.test(blocker)) { href = '/bookkeeping/voucher-gaps' actionLabel = 'Hantera nummerlucka' } else if (/trial balance/i.test(blocker)) { href = '/reports/trial-balance' actionLabel = 'Öppna balansrapport' } else if (/continuity/i.test(blocker)) { href = '/bookkeeping' actionLabel = 'Granska ingående balans' } return (

{blocker}

{href && actionLabel && ( {actionLabel} )}
) }