'use client' import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' import { Skeleton } from '@/components/ui/skeleton' import { QUIET_LINK_CLASS } from '@/components/ui/dry-table' import { AlertTriangle, Info, XCircle } 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 } /** Sans eyebrow section head with a trailing hairline (house idiom). */ function SectionHead({ icon, children }: { icon?: React.ReactNode; children: React.ReactNode }) { return (
{icon}

{children}

) } export function PreflightStep({ report, isLoading, error, onContinue }: PreflightStepProps) { if (isLoading) { return (
) } if (error) { return

{error}

} if (!report) { return null } return (
{/* Period line: muted text for the normal state, chip only when the period deviates (design.md: chips mark exceptions). */}

{report.period.name}

{report.period.period_start} till {report.period.period_end}
{report.ready ? ( Redo för bokslut ) : ( Inte redo )}
{report.blockers.length > 0 && (
{report.blockers.map((blocker, i) => ( ))}
)} {report.warnings.length > 0 && (
{report.warnings.map((warning, i) => (

{warning}

))}
)} {report.reminders.length > 0 && (
{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} )}
) }