import React, { useState, useEffect } from 'react'; import { motion } from 'framer-motion'; import { Building2, Save, CheckCircle, AlertCircle, RefreshCw, Briefcase } from 'lucide-react'; import toast from 'react-hot-toast'; import { getCompanyProfile, updateCompanyProfile, CompanyProfileData } from '../api/client'; import { SkeletonLoader } from '../components/common/SkeletonLoader'; const CompanyProfile: React.FC = () => { const [profile, setProfile] = useState({ nip: '', name: '', pkd_codes: [], company_size: 'mikro', location: '', description: '' }); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); const [pkdInput, setPkdInput] = useState(''); useEffect(() => { fetchProfile(); }, []); const fetchProfile = async () => { setLoading(true); try { const data = await getCompanyProfile(); setProfile({ nip: data.nip || '', name: data.name || '', pkd_codes: data.pkd_codes || [], company_size: data.company_size || 'mikro', location: data.location || '', description: data.description || '', is_verified: data.is_verified || false }); setPkdInput((data.pkd_codes || []).join(', ')); } catch (error) { console.error("Błąd ładowania profilu", error); toast.error("Nie udało się załadować danych firmy"); } finally { setLoading(false); } }; const handleSave = async (e: React.FormEvent) => { e.preventDefault(); if (!profile.nip) { toast.error("NIP jest wymagany"); return; } setSaving(true); try { // Przetwarzanie PKD const pkds = pkdInput.split(',') .map(p => p.trim()) .filter(p => p.length > 0); const updatedProfile = await updateCompanyProfile({ ...profile, pkd_codes: pkds }); setProfile(updatedProfile); setPkdInput((updatedProfile.pkd_codes || []).join(', ')); toast.success("Zapisano profil firmy"); } catch (error) { console.error("Błąd zapisywania", error); toast.error("Nie udało się zapisać profilu"); } finally { setSaving(false); } }; if (loading) { return (
); } return (

Mój Profil Firmy

Zapisz dane swojego przedsiębiorstwa, aby automatycznie dopasowywać naboru i generować precyzyjniejsze wnioski.

{profile.is_verified ? (
Dane firmy zweryfikowane

Status MŚP dla tego numeru NIP został automatycznie potwierdzony.

) : profile.nip ? (
Brak weryfikacji statusu MŚP

Zapisz poprawne dane, aby system dokonał walidacji w KRS/CEIDG.

) : null}
setProfile({...profile, nip: e.target.value})} placeholder="Np. 5213214567" required style={{ width: '100%', padding: '1rem', background: 'rgba(255,255,255,0.03)', border: '1px solid rgba(255,255,255,0.1)', borderRadius: '8px', color: '#fff' }} />
setProfile({...profile, name: e.target.value})} placeholder="Pełna nazwa przedsiębiorstwa" style={{ width: '100%', padding: '1rem', background: 'rgba(255,255,255,0.03)', border: '1px solid rgba(255,255,255,0.1)', borderRadius: '8px', color: '#fff' }} />
setPkdInput(e.target.value)} placeholder="Np. 62.01.Z, 72.19.Z" style={{ width: '100%', padding: '1rem 1rem 1rem 3rem', background: 'rgba(255,255,255,0.03)', border: '1px solid rgba(255,255,255,0.1)', borderRadius: '8px', color: '#fff' }} />
setProfile({...profile, location: e.target.value})} placeholder="Np. mazowieckie" style={{ width: '100%', padding: '1rem', background: 'rgba(255,255,255,0.03)', border: '1px solid rgba(255,255,255,0.1)', borderRadius: '8px', color: '#fff' }} />