import React, { useState, useRef, useEffect } from 'react'; import { askAgriMind } from '../services/geminiService'; import { AiResponse } from '../types'; import { Send, BrainCircuit, Loader2, Sprout, Sparkles } from 'lucide-react'; const AiAssistant: React.FC = () => { const [prompt, setPrompt] = useState(''); const [response, setResponse] = useState(null); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const chatEndRef = useRef(null); const handleAsk = async (e: React.FormEvent) => { e.preventDefault(); if (!prompt.trim()) return; setLoading(true); setError(''); setResponse(null); try { const result = await askAgriMind(prompt); setResponse(result); } catch (err) { setError('Üzgünüm, şu anda yanıt veremiyorum. Lütfen tekrar deneyin.'); } finally { setLoading(false); } }; useEffect(() => { if(response && chatEndRef.current) { chatEndRef.current.scrollIntoView({ behavior: 'smooth' }); } }, [response]); return (

AgriMind Web

Yapay zeka destekli tarım asistanınız. Sorularınızı sorun, bilimsel ve veriye dayalı yanıtlar alın.

{/* Chat Interface */}
{/* Response Area */}
{!response && !loading && !error && (

Örnek: "Buğday verimini artırmak için ne yapmalıyım?"

)} {loading && (
AgriMind Düşünüyor...

Karmaşık tarımsal verileri analiz ediyorum, lütfen bekleyin.

)} {error && (
{error}
)} {response && (

{response.title}

Hızlı İpuçları

    {response.tips.map((tip, idx) => (
  • {tip}
  • ))}

Detaylı Analiz

{response.detailed_answer}

)}
{/* Input Area */}