import React, { useState } from 'react'; import { Activity, HeartPulse, ShieldAlert, Stethoscope, MapPin, DollarSign, Package, HeartHandshake, Loader2, Info, LogOut, Plus, FileText, Image as ImageIcon, ChevronLeft, CheckCircle2, Clock, CheckCircle } from 'lucide-react'; import { DogProfile, MatchResult, DogWithMatches } from '../types'; import { evaluateDogProfile } from '../services/gemini'; import { useAppContext } from '../context/AppContext'; interface RescueIntakeViewProps { onLogout: () => void; } export default function RescueIntakeView({ onLogout }: RescueIntakeViewProps) { const { dogs, addDog, centers, updateDog } = useAppContext(); const [view, setView] = useState<'dashboard' | 'add' | 'detail' | 'edit'>('dashboard'); const [selectedDog, setSelectedDog] = useState(null); const [activeTab, setActiveTab] = useState<'overview' | 'documents' | 'matches'>('overview'); const [editDogForm, setEditDogForm] = useState>({}); const [newDog, setNewDog] = useState>({ name: '', breed: '', age: '', vetNotes: '' }); const [isAnalyzing, setIsAnalyzing] = useState(false); const handleAddDog = async (e: React.FormEvent) => { e.preventDefault(); if (!newDog.name || !newDog.vetNotes) return; setIsAnalyzing(true); try { const dogToAnalyze = newDog as DogProfile; const matches = await evaluateDogProfile(dogToAnalyze, centers); matches.sort((a, b) => b.decision.match_score - a.decision.match_score); const addedDog: DogWithMatches = { ...dogToAnalyze, id: `DOG-${Math.random().toString(36).substr(2, 9).toUpperCase()}`, status: 'analyzed', dateAdded: new Date().toISOString().split('T')[0], matches, placementStatus: 'unplaced', documents: ['Initial_Intake.pdf'] // Mock document }; addDog(addedDog); setNewDog({ name: '', breed: '', age: '', vetNotes: '' }); setView('dashboard'); } catch (err) { console.error(err); alert("Failed to analyze profile. Please try again."); } finally { setIsAnalyzing(false); } }; const openDogDetail = (dog: DogWithMatches) => { setSelectedDog(dog); setActiveTab('overview'); setView('detail'); }; return (
setView('dashboard')}>

Rescue-to-Rehab Engine

Rescue / Shelter Intake Portal

{/* DASHBOARD VIEW */} {view === 'dashboard' && (

My Uploaded Dogs

Manage your permanent medical and behavioral records.

{dogs.map(dog => (
openDogDetail(dog)} className="bg-white rounded-2xl shadow-sm border border-slate-200 overflow-hidden cursor-pointer hover:shadow-md hover:border-teal-300 transition-all group" >

{dog.name}

{dog.breed} • {dog.age}

{dog.placementStatus !== 'unplaced' ? ( Approved ) : dog.status === 'analyzed' && ( Analyzed )}

{dog.vetNotes}

Added {dog.dateAdded} {dog.matches?.length || 0} Matches Found
))}
)} {/* ADD DOG VIEW */} {view === 'add' && (

New Intake Profile

Submit a new dog to the permanent record system. Analysis will run automatically.

setNewDog({...newDog, name: e.target.value})} className="w-full rounded-xl border-slate-300 border px-4 py-2.5 focus:ring-2 focus:ring-teal-500 focus:border-transparent outline-none" placeholder="e.g. Barnaby" />
setNewDog({...newDog, breed: e.target.value})} className="w-full rounded-xl border-slate-300 border px-4 py-2.5 focus:ring-2 focus:ring-teal-500 focus:border-transparent outline-none" placeholder="e.g. Pitbull Mix" />
setNewDog({...newDog, age: e.target.value})} className="w-full rounded-xl border-slate-300 border px-4 py-2.5 focus:ring-2 focus:ring-teal-500 focus:border-transparent outline-none" placeholder="e.g. 4 years" />