import React, { useState } from 'react'; import { Building } from '../../types'; import { generateBuildingAudit } from '../../services/geminiService'; import { Users, Wallet, Activity, TrendingDown, Bot, Sparkles, CheckCircle2, Calendar } from 'lucide-react'; type TabType = 'overview' | 'finance' | 'inspections' | 'residents' | 'passport' | 'accounts'; export const OverviewView: React.FC<{ building: Building, onNavigate: (tab: TabType) => void }> = ({ building, onNavigate }) => { const [auditResult, setAuditResult] = useState(null); const [loadingAudit, setLoadingAudit] = useState(false); const handleAudit = async () => { setLoadingAudit(true); const res = await generateBuildingAudit(building); setAuditResult(res); setLoadingAudit(false); }; return (
{/* Main Info Card */}
Building

{building.passport.address}

{building.passport.general.constructionYear} г. • {building.passport.general.floors} эт. • {building.passport.general.totalArea} м²

NPS

= 0 ? 'text-emerald-400' : 'text-red-400'}`}>{building.nps > 0 ? '+' : ''}{building.nps}

onNavigate('residents')}>

Жителей

{building.accounts.reduce((sum, acc) => { const count = acc.registered?.length || acc.registeredCount || 0; return sum + (typeof count === 'number' ? count : 0); }, 0)}

onNavigate('finance')}>

Баланс

= 0 ? 'text-emerald-600' : 'text-red-600'}`}> {(building.financials.balance / 1000).toFixed(0)}k

onNavigate('inspections')}>

Состояние

Удовл.

onNavigate('passport')}>

Износ

35%

{/* AI Audit Section */}

Анализ Дома

Краткая сводка состояния дома, финансовых показателей и рекомендаций по эксплуатации на основе данных паспорта и истории осмотров.

{!auditResult ? ( ) : (
{auditResult}
)}
{/* Tasks Widget */}

Текущие задачи

{building.tasks.map(task => (

{task.title}

{task.deadline} {task.priority}

))}

План работ (Май)

{building.annualPlan.map(plan => (
{plan.workName} {plan.progress}%
))}
); };