import React, { useRef, useState } from 'react'; import { WizardState } from '../types'; import { UploadCloud, FileJson, AlertCircle } from 'lucide-react'; import { parseGpxFile } from '../utils/gpxUtils'; interface StepDataProps { data: WizardState; updateData: (updates: Partial) => void; } const StepData: React.FC = ({ data, updateData }) => { const fileInputRef = useRef(null); const [error, setError] = useState(null); const [isParsing, setIsParsing] = useState(false); const handleFileChange = async (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (!file) return; if (!file.name.toLowerCase().endsWith('.gpx')) { setError('Proszę wybrać plik .gpx'); return; } setError(null); setIsParsing(true); try { const stats = await parseGpxFile(file); updateData({ stats }); } catch (err) { console.error(err); setError('Błąd parsowania pliku GPX. Spróbuj innego pliku lub wpisz dane ręcznie.'); } finally { setIsParsing(false); } }; const handleStatsChange = (key: keyof typeof data.stats, value: string) => { updateData({ stats: { ...data.stats, [key]: value } }); }; return (

Dane Aktywności

Wgraj plik GPX lub wpisz dane ręcznie.

{/* Upload Zone */}
fileInputRef.current?.click()} > {isParsing ? (

Analizowanie pliku...

) : ( <>

Kliknij, aby wgrać plik GPX

lub przeciągnij i upuść tutaj

)}
{error && (
{error}
)} {/* Manual Override Inputs */}
handleStatsChange('distance', e.target.value)} className="w-full p-4 border border-gray-200 rounded-md focus:ring-1 focus:ring-[#EA4420] focus:border-[#EA4420] outline-none transition-all font-medium text-gray-900 placeholder-gray-300" placeholder="np. 12.5 km" />
handleStatsChange('duration', e.target.value)} className="w-full p-4 border border-gray-200 rounded-md focus:ring-1 focus:ring-[#EA4420] focus:border-[#EA4420] outline-none transition-all font-medium text-gray-900 placeholder-gray-300" placeholder="np. 1h 45m" />
handleStatsChange('elevation', e.target.value)} className="w-full p-4 border border-gray-200 rounded-md focus:ring-1 focus:ring-[#EA4420] focus:border-[#EA4420] outline-none transition-all font-medium text-gray-900 placeholder-gray-300" placeholder="np. 350m" />
); }; export default StepData;