Spaces:
Running
Running
File size: 32,071 Bytes
3b7f713 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | import React, { useState } from 'react';
import { User, Building2, CreditCard, Shield, Sliders, Lock, Settings as SettingsIcon, LogOut, Download, AlertTriangle } from 'lucide-react';
import { useUser, UserProfile, SignOutButton, useClerk } from '@clerk/clerk-react';
import { deleteUserAccount, getAccountExport, getSubscriptionStatus, updateAccountSettings, lookupCompany } from '../api/client';
import toast from 'react-hot-toast';
import { useQuery, useMutation } from '@tanstack/react-query';
import PricingModal from '../components/dashboard/PricingModal';
const Settings: React.FC = () => {
const [activeTab, setActiveTab] = useState('profile');
const { signOut } = useClerk();
const [showDeleteModal, setShowDeleteModal] = useState(false);
const [deleteInput, setDeleteInput] = useState('');
const [isDeleting, setIsDeleting] = useState(false);
const [deleteSuccess, setDeleteSuccess] = useState(false);
const [isExporting, setIsExporting] = useState(false);
// States for Pricing Modal and Companies
const [showPricing, setShowPricing] = useState(false);
const [companies, setCompanies] = useState(() => {
const saved = localStorage.getItem('grantforge_companies');
if (saved) {
try {
return JSON.parse(saved);
} catch (e) {
console.error("Błąd parsowania firm z LocalStorage", e);
}
}
return [
{ nip: '1234567890', name: 'GrantForge sp. z o.o.', city: 'Warszawa', status: 'Zatwierdzone' }
];
});
const [showCompanyModal, setShowCompanyModal] = useState(false);
const [newNip, setNewNip] = useState('');
const [isLookingUp, setIsLookingUp] = useState(false);
const [fetchedCompany, setFetchedCompany] = useState<any>(null);
const { data: subData, isLoading: subLoading, refetch: refetchSub } = useQuery({
queryKey: ['subscription-status'],
queryFn: getSubscriptionStatus
});
const updateSettingsMutation = useMutation({
mutationFn: updateAccountSettings,
onSuccess: () => {
toast.success("Ustawienia zostały zapisane.");
refetchSub();
},
onError: () => {
toast.error("Wystąpił błąd podczas zapisywania ustawień.");
}
});
const handleAddCompany = async () => {
if (!newNip || newNip.length < 10) {
toast.error("Wprowadź prawidłowy NIP (min. 10 cyfr).");
return;
}
setIsLookingUp(true);
try {
const data = await lookupCompany(newNip);
setFetchedCompany({
nip: data.nip,
name: data.name,
city: data.voivodeship,
address: `PKD: ${data.pkd ? data.pkd.join(', ') : 'Brak'}`,
legalForm: `Przychody: ${data.revenue || 'Brak danych'} PLN`
});
toast.success("Pobrano dane z bazy GUS.");
} catch (err: any) {
toast.error(err.response?.data?.detail || "Nie udało się pobrać danych z GUS.");
} finally {
setIsLookingUp(false);
}
};
const handleSaveFetchedCompany = () => {
if (!fetchedCompany) return;
const newCompany = {
nip: fetchedCompany.nip,
name: fetchedCompany.name,
city: fetchedCompany.city,
status: 'Zatwierdzone'
};
const updatedCompanies = [...companies, newCompany];
setCompanies(updatedCompanies);
localStorage.setItem('grantforge_companies', JSON.stringify(updatedCompanies));
setShowCompanyModal(false);
setNewNip('');
setFetchedCompany(null);
toast.success("Podmiot dodany pomyślnie.");
};
const handleRemoveCompany = (nipToRemove: string) => {
const updatedCompanies = companies.filter((c: any) => c.nip !== nipToRemove);
setCompanies(updatedCompanies);
localStorage.setItem('grantforge_companies', JSON.stringify(updatedCompanies));
toast.success("Podmiot został usunięty.");
};
const handleExportData = async () => {
setIsExporting(true);
try {
const data = await getAccountExport();
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', `dotacje_ai_export_${new Date().toISOString().split('T')[0]}.json`);
document.body.appendChild(link);
link.click();
link.remove();
toast.success("Dane zostały wyeksportowane.");
} catch (error) {
toast.error("Wystąpił błąd podczas eksportu.");
} finally {
setIsExporting(false);
}
};
const handleDeleteAccount = async () => {
if (deleteInput !== 'USUŃ') return;
setIsDeleting(true);
try {
await deleteUserAccount();
setDeleteSuccess(true);
setShowDeleteModal(false);
toast.success(
"Twoje dane w Dotacje AI zostały trwale usunięte. Za chwilę zostaniesz wylogowany.",
{ duration: 8000 }
);
// Sign out after a short delay so they can read the toast or internal message
setTimeout(() => {
signOut();
}, 6000);
} catch (error) {
toast.error("Wystąpił błąd podczas usuwania danych.");
} finally {
setIsDeleting(false);
}
};
const tabs = [
{ id: 'profile', label: 'Profil i Konto', icon: <User size={18} /> },
{ id: 'companies', label: 'Moje Firmy', icon: <Building2 size={18} /> },
{ id: 'billing', label: 'Subskrypcja', icon: <CreditCard size={18} /> },
{ id: 'security', label: 'Bezpieczeństwo', icon: <Shield size={18} /> },
{ id: 'preferences', label: 'Preferencje', icon: <Sliders size={18} /> },
{ id: 'privacy', label: 'Dane i Prywatność', icon: <Lock size={18} /> },
];
const renderContent = () => {
switch (activeTab) {
case 'profile':
return (
<div style={{ animation: 'fadeIn 0.3s ease' }}>
<h2 style={{ fontSize: '1.4rem', borderBottom: '1px solid rgba(255,255,255,0.1)', paddingBottom: '1rem', marginBottom: '1.5rem', color: '#fff' }}>Twój Profil</h2>
<div style={{ background: 'var(--bg-elevated)', border: '1px solid rgba(255,255,255,0.05)', borderRadius: '12px', padding: '1rem', overflow: 'hidden' }}>
{/* We use Clerk's pre-built profile component embedded here */}
<UserProfile
appearance={{
elements: {
rootBox: { width: '100%', maxWidth: '100%' },
card: { boxShadow: 'none', background: 'transparent', padding: 0 }
}
}}
/>
</div>
</div>
);
case 'companies':
return (
<div style={{ animation: 'fadeIn 0.3s ease' }}>
<h2 style={{ fontSize: '1.4rem', borderBottom: '1px solid rgba(255,255,255,0.1)', paddingBottom: '1rem', marginBottom: '1.5rem', color: '#fff' }}>Zarządzanie podmiotami (Moje Firmy)</h2>
{companies.map((c, i) => (
<div key={i} className="glass-card" style={{ marginBottom: '1rem' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<h4 style={{ margin: '0 0 0.3rem 0', fontSize: '1.1rem' }}>{c.name}</h4>
<p style={{ margin: 0, color: 'var(--text-muted)', fontSize: '0.9rem' }}>NIP: {c.nip} • {c.city} • {c.status}</p>
</div>
<button className="btn btn-secondary" style={{ color: '#ef4444', borderColor: 'rgba(239, 68, 68, 0.3)' }} onClick={() => handleRemoveCompany(c.nip)}>Usuń</button>
</div>
</div>
))}
<button
className="btn btn-primary"
style={{ marginTop: '1rem', display: 'flex', alignItems: 'center', gap: '0.5rem' }}
onClick={() => setShowCompanyModal(true)}
>
+ Dodaj nową firmę z GUS
</button>
</div>
);
case 'billing':
return (
<div style={{ animation: 'fadeIn 0.3s ease' }}>
<h2 style={{ fontSize: '1.4rem', borderBottom: '1px solid rgba(255,255,255,0.1)', paddingBottom: '1rem', marginBottom: '1.5rem', color: '#fff' }}>Subskrypcja i Rozliczenia</h2>
<div style={{ background: 'linear-gradient(135deg, rgba(16,185,129,0.1), rgba(59,130,246,0.1))', border: '1px solid rgba(16,185,129,0.3)', padding: '2rem', borderRadius: '12px', marginBottom: '2rem' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<div style={{ color: 'var(--accent-green)', fontWeight: 800, textTransform: 'uppercase', marginBottom: '0.5rem', letterSpacing: '2px' }}>Aktywny Plan</div>
<h3 style={{ fontSize: '1.8rem', margin: 0, color: '#fff' }}>
{subLoading ? '...' : (subData?.tier || 'FREE').toUpperCase()}
</h3>
<p style={{ color: 'var(--text-muted)', margin: '0.5rem 0 0 0' }}>Dostęp do wszystkich sekcji i nielimitowane analizy RAG.</p>
</div>
<button className="btn btn-primary" style={{ background: 'var(--accent-blue)', color: '#fff' }} onClick={() => setShowPricing(true)}>Zmień Plan</button>
</div>
</div>
<div className="glass-card">
<h4 style={{ margin: '0 0 1rem 0' }}>Historia Płatności</h4>
<p style={{ color: 'var(--text-muted)', fontSize: '0.9rem' }}>Nie posiadasz jeszcze historii faktur dla tego konta.</p>
</div>
</div>
);
case 'security':
return (
<div style={{ animation: 'fadeIn 0.3s ease' }}>
<h2 style={{ fontSize: '1.4rem', borderBottom: '1px solid rgba(255,255,255,0.1)', paddingBottom: '1rem', marginBottom: '1.5rem', color: '#fff' }}>Bezpieczeństwo</h2>
<div className="glass-card" style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', paddingBottom: '1rem', borderBottom: '1px solid rgba(255,255,255,0.05)' }}>
<div>
<h4 style={{ margin: '0 0 0.3rem 0' }}>Weryfikacja dwuetapowa (2FA)</h4>
<p style={{ margin: 0, color: 'var(--text-muted)', fontSize: '0.9rem' }}>Zarządzaj zabezpieczeniami w panelu Profilu (Clerk).</p>
</div>
<button className="btn btn-secondary" onClick={() => setActiveTab('profile')}>Skonfiguruj w Profilu</button>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', paddingBottom: '1rem', borderBottom: '1px solid rgba(255,255,255,0.05)' }}>
<div>
<h4 style={{ margin: '0 0 0.3rem 0' }}>Aktywne Sesje</h4>
<p style={{ margin: 0, color: 'var(--text-muted)', fontSize: '0.9rem' }}>Windows 11 / Chrome • Aktualna sesja</p>
</div>
<button className="btn hover-bg" style={{ color: 'var(--text-primary)', border: '1px solid var(--border-strong)', background: 'var(--bg-surface)' }}>Wyloguj inne urządzenia</button>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<h4 style={{ margin: '0 0 0.3rem 0' }}>Konto i dostęp</h4>
</div>
<SignOutButton>
<button className="btn hover-bg" style={{ background: '#ef4444', border: 'none', color: '#fff', display: 'flex', alignItems: 'center', gap: '0.5rem', fontWeight: 600, padding: '0.5rem 1rem', borderRadius: '6px' }}>
<LogOut size={16} /> Wyloguj się
</button>
</SignOutButton>
</div>
</div>
</div>
);
case 'preferences':
const aiDisclaimer = subData?.settings?.ai_disclaimer_enabled ?? true;
const gdprConsent = subData?.settings?.gdpr_consent_accepted ?? false;
return (
<div style={{ animation: 'fadeIn 0.3s ease' }}>
<h2 style={{ fontSize: '1.4rem', borderBottom: '1px solid rgba(255,255,255,0.1)', paddingBottom: '1rem', marginBottom: '1.5rem', color: '#fff' }}>Preferencje Aplikacji</h2>
<div className="glass-card" style={{ display: 'flex', flexDirection: 'column', gap: '1.5rem' }}>
<div>
<label style={{ display: 'block', fontSize: '0.9rem', color: 'var(--text-secondary)', marginBottom: '0.5rem' }}>Język interfejsu</label>
<select className="form-input" style={{ width: '100%', maxWidth: '300px' }}>
<option>Polski</option>
<option>English</option>
</select>
</div>
<div>
<label style={{ display: 'block', fontSize: '0.9rem', color: 'var(--text-secondary)', marginBottom: '0.5rem' }}>Powiadomienia E-mail</label>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.8rem', marginBottom: '0.5rem' }}>
<input type="checkbox" id="n1" defaultChecked /> <label htmlFor="n1" style={{ color: '#fff' }}>Powiadomienia o nowych naborach ze statusem "Wkrótce"</label>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.8rem' }}>
<input type="checkbox" id="n2" defaultChecked /> <label htmlFor="n2" style={{ color: '#fff' }}>Cotygodniowe podsumowanie wniosków</label>
</div>
</div>
<div>
<label style={{ display: 'block', fontSize: '0.9rem', color: 'var(--text-secondary)', marginBottom: '0.5rem' }}>Prywatność i ostrzeżenia</label>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.8rem', marginBottom: '0.5rem' }}>
<input
type="checkbox"
id="p1"
checked={gdprConsent}
onChange={(e) => updateSettingsMutation.mutate({ gdpr_consent_accepted: e.target.checked })}
disabled={updateSettingsMutation.isPending}
/>
<label htmlFor="p1" style={{ color: '#fff' }}>Zgoda na przetwarzanie danych profilowych (RODO)</label>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.8rem' }}>
<input
type="checkbox"
id="p2"
checked={aiDisclaimer}
onChange={(e) => updateSettingsMutation.mutate({ ai_disclaimer_enabled: e.target.checked })}
disabled={updateSettingsMutation.isPending}
/>
<label htmlFor="p2" style={{ color: '#fff' }}>Wyświetlaj ostrzeżenia AI (Disclaimer)</label>
</div>
</div>
</div>
</div>
);
case 'privacy':
return (
<div style={{ animation: 'fadeIn 0.3s ease' }}>
<h2 style={{ fontSize: '1.4rem', borderBottom: '1px solid rgba(255,255,255,0.1)', paddingBottom: '1rem', marginBottom: '1.5rem', color: '#fff' }}>Dane i Prywatność</h2>
<div className="glass-card" style={{ display: 'flex', flexDirection: 'column', gap: '1.5rem' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
<div>
<h4 style={{ margin: '0 0 0.3rem 0', display: 'flex', alignItems: 'center', gap: '0.5rem' }}><Download size={18} color="var(--accent-blue)" /> Pobierz moje dane</h4>
<p style={{ margin: 0, color: 'var(--text-muted)', fontSize: '0.9rem', maxWidth: '400px' }}>
Weksportuj paczkę ze wszystkimi Twoimi wnioskami i projektami w czytelnym formacie maszynowym (JSON).
</p>
</div>
<button className="btn btn-secondary" onClick={handleExportData} disabled={isExporting}>
{isExporting ? 'Przygotowywanie...' : 'Zażądaj archiwum JSON'}
</button>
</div>
<hr style={{ border: 'none', borderTop: '1px solid rgba(255,255,255,0.05)', margin: '0' }} />
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
<div>
<h4 style={{ margin: '0 0 0.3rem 0', color: 'var(--accent-red)', display: 'flex', alignItems: 'center', gap: '0.5rem' }}><AlertTriangle size={18} /> Usuń konto</h4>
<p style={{ margin: 0, color: 'var(--text-muted)', fontSize: '0.9rem', maxWidth: '400px' }}>
Usunięcie konta jest nieodwracalne i obejmuje wszystkie Twoje projekty oraz dane w systemie.
</p>
</div>
<button className="btn" onClick={() => setShowDeleteModal(true)} style={{ background: 'rgba(239, 68, 68, 0.1)', border: '1px solid var(--accent-red)', color: 'var(--accent-red)' }}>Usuń moje konto i wszystkie dane</button>
</div>
</div>
{deleteSuccess && (
<div style={{ marginTop: '2rem', padding: '1.5rem', background: 'rgba(34, 197, 94, 0.1)', border: '1px solid #22c55e', borderRadius: '12px' }}>
<h3 style={{ color: '#22c55e', marginTop: 0 }}>Twoje dane w Dotacje AI zostały trwale usunięte.</h3>
<p style={{ color: 'var(--text-primary)', marginBottom: 0 }}>
Jeśli chcesz całkowicie usunąć konto logowania, przejdź do swojego profilu w Clerk → Manage Account → Delete Account.
</p>
</div>
)}
{showDeleteModal && (
<div style={{
position: 'fixed', top: 0, left: 0, right: 0, bottom: 0,
background: 'rgba(0,0,0,0.8)', zIndex: 9999,
display: 'flex', alignItems: 'center', justifyContent: 'center'
}}>
<div style={{
background: 'var(--bg-elevated)', padding: '2rem',
borderRadius: '12px', width: '100%', maxWidth: '400px',
border: '1px solid rgba(255,255,255,0.1)'
}}>
<h3 style={{ marginTop: 0, color: 'var(--accent-red)', display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
<AlertTriangle /> Potwierdź usunięcie
</h3>
<p style={{ color: 'var(--text-secondary)', fontSize: '0.9rem', lineHeight: 1.5 }}>
Ta operacja jest niemożliwa do cofnięcia. Kasujemy wszystkie projekty, logi i dane o zużyciu.
<br/><br/>
Aby potwierdzić, wpisz słowo <strong>USUŃ</strong> poniżej:
</p>
<input
type="text"
className="form-input"
value={deleteInput}
onChange={(e) => setDeleteInput(e.target.value)}
placeholder="Wpisz USUŃ"
style={{ width: '100%', marginBottom: '1.5rem', marginTop: '0.5rem', boxSizing: 'border-box' }}
/>
<div style={{ display: 'flex', gap: '1rem', justifyContent: 'flex-end' }}>
<button className="btn btn-secondary" onClick={() => { setShowDeleteModal(false); setDeleteInput(''); }} disabled={isDeleting}>Anuluj</button>
<button
className="btn"
disabled={deleteInput !== 'USUŃ' || isDeleting}
onClick={handleDeleteAccount}
style={{ background: 'var(--accent-red)', color: 'white', opacity: deleteInput !== 'USUŃ' ? 0.5 : 1 }}
>
{isDeleting ? 'Usuwanie...' : 'Skasuj bezpowrotnie'}
</button>
</div>
</div>
</div>
)}
</div>
);
default:
return null;
}
};
return (
<div style={{ padding: '2rem', maxWidth: '1200px', width: '100%', margin: '0 auto', display: 'flex', gap: '3rem', minHeight: 'calc(100vh - 4rem)', alignItems: 'flex-start' }}>
{/* Lewy nawigator */}
<div style={{ width: '280px', flexShrink: 0 }}>
<h1 style={{ fontSize: '1.8rem', fontWeight: 800, margin: '0 0 2rem 0', display: 'flex', alignItems: 'center', gap: '0.8rem' }}>
<SettingsIcon color="var(--accent-blue)" /> Ustawienia
</h1>
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
{tabs.map((tab) => (
<button
key={tab.id}
onClick={() => setActiveTab(tab.id)}
style={{
display: 'flex', alignItems: 'center', gap: '0.8rem',
padding: '1rem', borderRadius: '8px', border: 'none',
background: activeTab === tab.id ? 'var(--bg-elevated)' : 'transparent',
color: activeTab === tab.id ? 'var(--text-primary)' : 'var(--text-secondary)',
fontWeight: activeTab === tab.id ? 600 : 500,
cursor: 'pointer',
transition: 'all 0.2s',
textAlign: 'left'
}}
className="hover-bg"
>
<span style={{ color: activeTab === tab.id ? 'var(--accent-blue)' : 'inherit' }}>{tab.icon}</span>
{tab.label}
</button>
))}
</div>
</div>
{/* Prawy panel zwartości */}
<div style={{ flex: 1, paddingRight: '2rem' }}>
{renderContent()}
</div>
{showPricing && <PricingModal onClose={() => setShowPricing(false)} />}
{showCompanyModal && (
<div style={{
position: 'fixed', top: 0, left: 0, right: 0, bottom: 0,
background: 'rgba(0,0,0,0.8)', zIndex: 9999,
display: 'flex', alignItems: 'center', justifyContent: 'center'
}}>
<div style={{
background: 'var(--bg-elevated)', padding: '2rem',
borderRadius: '12px', width: '100%', maxWidth: '500px',
border: '1px solid rgba(255,255,255,0.1)'
}}>
<h3 style={{ marginTop: 0, color: 'var(--text-primary)' }}>Dodaj firmę z GUS</h3>
{!fetchedCompany ? (
<>
<p style={{ color: 'var(--text-secondary)', fontSize: '0.9rem', marginBottom: '1.5rem' }}>
Podaj NIP podmiotu. System pobierze dane z Głównego Urzędu Statystycznego i zweryfikuje powiązania KRS.
</p>
<input
type="text"
className="form-input"
value={newNip}
onChange={(e) => setNewNip(e.target.value)}
placeholder="Wpisz 10-cyfrowy NIP"
style={{ width: '100%', marginBottom: '1.5rem', boxSizing: 'border-box' }}
/>
<div style={{ display: 'flex', gap: '1rem', justifyContent: 'flex-end' }}>
<button className="btn btn-secondary" onClick={() => { setShowCompanyModal(false); setNewNip(''); }} disabled={isLookingUp}>Anuluj</button>
<button
className="btn btn-primary"
disabled={!newNip || newNip.length < 10 || isLookingUp}
onClick={handleAddCompany}
>
{isLookingUp ? 'Pobieranie danych...' : 'Pobierz dane'}
</button>
</div>
</>
) : (
<>
<div style={{ background: 'rgba(255,255,255,0.03)', padding: '1.5rem', borderRadius: '8px', marginBottom: '1.5rem' }}>
<h4 style={{ margin: '0 0 1rem 0', color: 'var(--accent-green)' }}>Znaleziono podmiot</h4>
<div style={{ display: 'grid', gridTemplateColumns: '120px 1fr', gap: '0.8rem', fontSize: '0.9rem' }}>
<div style={{ color: 'var(--text-muted)' }}>Nazwa:</div>
<div style={{ fontWeight: 600 }}>{fetchedCompany.name}</div>
<div style={{ color: 'var(--text-muted)' }}>NIP:</div>
<div>{fetchedCompany.nip}</div>
<div style={{ color: 'var(--text-muted)' }}>Adres:</div>
<div>{fetchedCompany.address}</div>
<div style={{ color: 'var(--text-muted)' }}>Miejscowość:</div>
<div>{fetchedCompany.city}</div>
<div style={{ color: 'var(--text-muted)' }}>Forma prawna:</div>
<div>{fetchedCompany.legalForm}</div>
</div>
<div style={{ marginTop: '1rem', padding: '0.8rem', background: 'rgba(34, 197, 94, 0.1)', border: '1px solid rgba(34, 197, 94, 0.3)', borderRadius: '6px', fontSize: '0.85rem', color: 'var(--accent-green)' }}>
✓ Zweryfikowano w bazie REGON
<br/>✓ Brak powiązań kapitałowych wykluczających MŚP
</div>
</div>
<div style={{ display: 'flex', gap: '1rem', justifyContent: 'flex-end' }}>
<button className="btn btn-secondary" onClick={() => setFetchedCompany(null)}>Wróć</button>
<button className="btn btn-primary" onClick={handleSaveFetchedCompany}>Dodaj do konta</button>
</div>
</>
)}
</div>
</div>
)}
<style>{`
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.hover-bg:hover { background: rgba(255,255,255,0.03) !important; color: #fff !important; }
.form-input { background: var(--bg-deep); border: 1px solid rgba(255,255,255,0.1); color: #fff; padding: 0.8rem 1rem; border-radius: 8px; outline: none; transition: 0.2s; }
.form-input:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 2px rgba(59,130,246,0.2); }
`}</style>
</div>
);
};
export default Settings;
|