import React, { useState, useEffect } from 'react'; import { initializeApp } from 'firebase/app'; import { getFirestore, collection, addDoc, getDocs, query, where, serverTimestamp, onSnapshot } from 'firebase/firestore'; import { getAuth, signInAnonymously, onAuthStateChanged } from 'firebase/auth'; import { Search, Car, ShieldCheck, AlertTriangle, CheckCircle2, History, Download, Fuel, Calendar, MapPin, Info, ChevronLeft, Upload, User } from 'lucide-react'; // --- CONFIGURARE SISTEM GOOGLE (FIREBASE) --- // Datele sunt injectate automat de mediu const firebaseConfig = JSON.parse(__firebase_config); const app = initializeApp(firebaseConfig); const db = getFirestore(app); const auth = getAuth(app); const appId = typeof __app_id !== 'undefined' ? __app_id : 'masini-verificate'; // --- COMPONENTE UI --- const StatusBadge = ({ status, text }) => { const configs = { ok: { color: "text-emerald-600 bg-emerald-50 border-emerald-100", icon: , label: "Fără probleme" }, attention: { color: "text-amber-600 bg-amber-50 border-amber-100", icon: , label: "Atenție" }, unknown: { color: "text-gray-400 bg-gray-50 border-gray-100", icon: , label: "Necunoscut" } }; const config = configs[status] || configs.unknown; return (
{config.icon} {text || config.label}
); }; // --- PAGINA PRINCIPALĂ --- const HomePage = ({ onSearch, listings }) => { const [vin, setVin] = useState(''); const handleSearch = (e) => { e.preventDefault(); if (vin.length === 17) onSearch(vin.toUpperCase()); else alert("VIN-ul trebuie să aibă 17 caractere!"); }; return (
Verificări Comunitare Securizate de Google

Verifică istoricul
oricărei mașini.

Accesează rapoartele de istoric încărcate de alți utilizatori și cumpără în siguranță.

setVin(e.target.value.toUpperCase())} maxLength={17} />

Cele mai recente mașini adăugate

{listings.length > 0 ? listings.map((car) => (
onSearch(car.vin)} className="bg-white p-6 rounded-3xl border border-slate-100 shadow-sm hover:shadow-xl transition-all cursor-pointer group">

{car.make} {car.model}

{car.vin}

{car.year}
)) : (
Se încarcă datele din Google Cloud...
)}
); }; // --- PAGINA RAPORT --- const ReportPage = ({ car, onBack }) => { if (!car) return (

VIN Negăsit

Această serie nu există încă în baza noastră de date. Dacă ai un raport PDF pentru ea, te rugăm să îl adaugi!

); return (
Raport Google Cloud Verificat

{car.make} {car.model}

{car.vin}
{car.fuel} {car.year} {car.country}

Daune înregistrate

{car.details || "Nicio daună raportată în istoricul disponibil."}

Kilometraj

Verificat

{Number(car.km).toLocaleString('ro-RO')} km

Statut Legal Curat

Raportul PDF original este disponibil

Poți descărca fișierul complet care include fotografii de la licitație și detalii de service.

); }; // --- APP --- export default function App() { const [view, setView] = useState('home'); const [user, setUser] = useState(null); const [listings, setListings] = useState([]); const [selectedCar, setSelectedCar] = useState(null); // 1. Autentificare Google (Anonimă pentru simplitate) useEffect(() => { const login = async () => { await signInAnonymously(auth); }; login(); onAuthStateChanged(auth, setUser); }, []); // 2. Citire date din Google Cloud (Real-time) useEffect(() => { if (!user) return; // Calea conform Regulii 1: /artifacts/{appId}/public/data/listings const listingsRef = collection(db, 'artifacts', appId, 'public', 'data', 'listings'); // Ascultăm schimbările în timp real const unsubscribe = onSnapshot(listingsRef, (snapshot) => { const data = snapshot.docs.map(doc => ({ id: doc.id, ...doc.data() })); setListings(data); }, (error) => { console.error("Eroare Google Cloud:", error); }); return () => unsubscribe(); }, [user]); const handleSearch = (vin) => { const match = listings.find(c => c.vin === vin.trim().toUpperCase()); setSelectedCar(match || null); setView('report'); window.scrollTo(0, 0); }; const handleAddTestCar = async () => { if (!user) return; try { const listingsRef = collection(db, 'artifacts', appId, 'public', 'data', 'listings'); await addDoc(listingsRef, { vin: 'SADCB2BN4JA236050', make: 'Jaguar', model: 'F-Pace', year: 2018, fuel: 'Diesel', km: 192346, country: 'Belgia', status_damage: 'attention', details: 'Avarie laterală dreapta în 2018. Reparație estimată la 12.000 RON.', created_at: serverTimestamp() }); alert("Mașină de test adăugată în Google Cloud!"); } catch (e) { alert("Eroare: " + e.message); } }; return (
{view === 'home' ? ( ) : ( setView('home')} /> )}
); }