'use client' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { CheckCircle2, XCircle, ArrowRight, AlertTriangle } from 'lucide-react' import Link from 'next/link' export type RegisterResult = { success: boolean created: number updated: number skipped: number failed: number errors: { row_index: number; name: string; reason: string }[] /** Non-fatal notes (e.g. dropped revenue-account overrides on article import). */ warnings?: string[] } interface RegisterResultStepProps { entity: 'customers' | 'suppliers' | 'articles' result: RegisterResult onNewImport: () => void } const ENTITY_COPY = { customers: { successTitle: 'Kunder importerade', failTitle: 'Importen misslyckades', listLabel: 'Visa alla kunder', listHref: '/customers', }, suppliers: { successTitle: 'Leverantörer importerade', failTitle: 'Importen misslyckades', listLabel: 'Visa alla leverantörer', listHref: '/suppliers', }, articles: { successTitle: 'Artiklar importerade', failTitle: 'Importen misslyckades', listLabel: 'Visa alla artiklar', listHref: '/articles', }, } as const export default function RegisterResultStep({ entity, result, onNewImport, }: RegisterResultStepProps) { const copy = ENTITY_COPY[entity] const totalProcessed = result.created + result.updated + result.skipped + result.failed const isPartial = result.failed > 0 && result.created + result.updated > 0 return (
{result.success ? ( ) : isPartial ? ( ) : ( )} {result.success ? copy.successTitle : isPartial ? 'Import slutförd med fel' : copy.failTitle}
{/* Stats */}
0 ? 'destructive' : 'muted'} />
{totalProcessed === 0 && (

Inga rader bearbetades.

)} {/* Errors */} {result.errors.length > 0 && (

Rader som inte kunde importeras

    {result.errors.map((e, i) => (
  • Rad {e.row_index}: {e.name} — {e.reason}
  • ))}
)} {/* Warnings (non-fatal — e.g. dropped revenue-account overrides) */} {result.warnings && result.warnings.length > 0 && (

Att notera

    {result.warnings.map((w, i) => (
  • {w}
  • ))}
)}
) } function Stat({ label, value, accent, }: { label: string value: number accent?: 'success' | 'warning' | 'destructive' | 'muted' }) { return (

{value}

{label}

) }