import React, { useState, useEffect } from “react”; import { Card, CardContent } from “@/components/ui/card”; import { Button } from “@/components/ui/button”; import { Input } from “@/components/ui/input”; import { motion } from “framer-motion”; import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer } from “recharts”; export default function CoffeeOSAdvanced() { const [screen, setScreen] = useState(“login”); const [role, setRole] = useState(null); const [chat, setChat] = useState([]); const [input, setInput] = useState(“”); const [data, setData] = useState([]); useEffect(() => { const interval = setInterval(() => { setData((prev) => [ …prev.slice(-9), { value: Math.floor(Math.random() * 100) + 50 } ]); }, 1500); return () => clearInterval(interval); }, []); const sendMessage = () => { if (!input) return; const userMsg = { sender: “user”, text: input }; const aiMsg = { sender: “ai”, text: “AI Insight: Optimize roast curve by reducing temp by 2°C” }; setChat([…chat, userMsg, aiMsg]); setInput(“”); }; const ScreenWrapper = ({ children }) => ( {children} ); if (screen === “login”) { return (

Login to CoffeeOS

); } if (screen === “dashboard”) { return (

☕ CoffeeOS ({role})

Live Yield / Price Data

); } if (screen === “map”) { return (

🌍 Farm to Export Map

Nyeri Farm → Nairobi Mill → Mombasa Port → Export

); } if (screen === “chat”) { return (

🤖 AI Assistant

{chat.map((c, i) => (

{c.sender}: {c.text}

))}
setInput(e.target.value)} />
); } if (screen === “trace”) { return (

🔗 Scan Coffee

Simulated QR Scan Result:

Origin: Nyeri

Farmer: Verified

Status: Blockchain Confirmed ✅

); } if (screen === “blockchain”) { return (

📜 Blockchain Ledger

Tx#10234 – Farm Upload

Tx#10298 – Processing

Tx#10322 – Export

); } }