'use client' import { useState, useCallback, useEffect } from 'react' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Progress } from '@/components/ui/progress' import { Upload, FileText, AlertCircle, CheckCircle, Loader2 } from 'lucide-react' const LOADING_PHASES = [ { message: 'Läser fil...', progress: 10 }, { message: 'Identifierar teckenkodning...', progress: 30 }, { message: 'Tolkar SIE-data...', progress: 55 }, { message: 'Matchar konton mot BAS-kontoplanen...', progress: 85 }, ] as const interface SIEUploadStepProps { onFileSelect: (file: File) => void isLoading: boolean error: string | null errorType?: 'duplicate' | 'duplicate_period' | 'validation' | 'parse' } export default function SIEUploadStep({ onFileSelect, isLoading, error, errorType }: SIEUploadStepProps) { const [isDragging, setIsDragging] = useState(false) const [selectedFile, setSelectedFile] = useState(null) const [loadingPhase, setLoadingPhase] = useState(0) // Cycle through loading phases on timers useEffect(() => { if (!isLoading) { setLoadingPhase(0) return } const timers = [ setTimeout(() => setLoadingPhase(1), 2000), setTimeout(() => setLoadingPhase(2), 4000), setTimeout(() => setLoadingPhase(3), 7000), ] return () => timers.forEach(clearTimeout) }, [isLoading]) const handleDragOver = useCallback((e: React.DragEvent) => { e.preventDefault() setIsDragging(true) }, []) const handleDragLeave = useCallback((e: React.DragEvent) => { e.preventDefault() setIsDragging(false) }, []) const handleDrop = useCallback((e: React.DragEvent) => { e.preventDefault() setIsDragging(false) const files = e.dataTransfer.files if (files.length > 0) { const file = files[0] if (file.name.toLowerCase().endsWith('.sie') || file.name.toLowerCase().endsWith('.se')) { setSelectedFile(file) onFileSelect(file) } } }, [onFileSelect]) const handleFileInput = useCallback((e: React.ChangeEvent) => { const files = e.target.files if (files && files.length > 0) { setSelectedFile(files[0]) onFileSelect(files[0]) } }, [onFileSelect]) const phase = LOADING_PHASES[loadingPhase] // Full-card takeover while analyzing the file if (isLoading && selectedFile) { return (

{phase.message}

{selectedFile.name} ({(selectedFile.size / 1024).toFixed(1)} KB)

Lämna inte sidan förrän analysen är klar

) } return (
Ladda upp SIE-fil Exportera en SIE4-fil från ditt nuvarande bokföringssystem (Fortnox, Visma, etc.) och ladda upp den här för att importera din bokföring. {/* Drop zone */}
document.getElementById('file-input')?.click()} > {selectedFile ? (

{selectedFile.name}

{(selectedFile.size / 1024).toFixed(1)} KB

) : (

Dra och släpp SIE-fil här

Tryck för att välja SIE-fil

eller klicka för att välja fil

.sie eller .se-filer

)}
{/* Error display */} {error && (

{errorType === 'duplicate' || errorType === 'duplicate_period' ? 'Filen har redan importerats' : 'Kunde inte läsa filen'}

{error}

)}
{/* Info cards */}
Vad är SIE?

SIE (Standard Import Export) är det svenska standardformatet för att överföra bokföringsdata mellan system. Det används av alla större bokföringsprogram i Sverige.

Vilken SIE-typ?
  • SIE4 - Full historik med alla verifikationer (rekommenderas)
  • SIE1 - Endast årssaldon (enklare import)
{/* Export instructions */} Så exporterar du från...

Fortnox

Inställningar → Import/Export → Exportera SIE

Visma eEkonomi

Rapporter → Övrigt → Exportera till SIE

Bokio

Inställningar → Bokföring → Exportera SIE-fil

) }