import { useState } from 'react'; import { Card, CardContent, CardHeader, CardTitle } from './ui/card'; import { Button } from './ui/button'; import { Badge } from './ui/badge'; import { Tabs, TabsContent, TabsList, TabsTrigger } from './ui/tabs'; import { Slider } from './ui/slider'; import { TrendingUp, Brain, Target, Zap, DollarSign, Fish, Activity } from 'lucide-react'; import { LineChart, Line, BarChart, Bar, AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Legend } from 'recharts'; import { User, Farm } from '../types'; interface AnalyticsProps { user: User; selectedFarm: Farm | null; } export default function Analytics({ user, selectedFarm }: AnalyticsProps) { const [predictionDays, setPredictionDays] = useState([30]); const [feedRate, setFeedRate] = useState([3.5]); const [temperature, setTemperature] = useState([26]); // Growth Prediction Data const growthPrediction = [ { week: 'Week 1', actual: 120, predicted: 122 }, { week: 'Week 2', actual: 145, predicted: 147 }, { week: 'Week 3', actual: 175, predicted: 173 }, { week: 'Week 4', actual: 210, predicted: 208 }, { week: 'Week 5', actual: 245, predicted: 248 }, { week: 'Week 6', actual: 285, predicted: 287 }, { week: 'Week 7', predicted: 328 }, { week: 'Week 8', predicted: 372 }, ]; // Profitability Analysis const profitabilityData = [ { month: 'May', revenue: 38000, costs: 28500, profit: 9500 }, { month: 'Jun', revenue: 42000, costs: 30200, profit: 11800 }, { month: 'Jul', revenue: 45000, costs: 31800, profit: 13200 }, { month: 'Aug', revenue: 48000, costs: 33500, profit: 14500 }, { month: 'Sep', revenue: 51000, costs: 35100, profit: 15900 }, { month: 'Oct', revenue: 54000, costs: 36800, profit: 17200 }, ]; // FCR Trends const fcrTrends = [ { date: 'Sep 15', fcr: 1.42, target: 1.40 }, { date: 'Sep 22', fcr: 1.38, target: 1.40 }, { date: 'Sep 29', fcr: 1.35, target: 1.40 }, { date: 'Oct 06', fcr: 1.37, target: 1.40 }, { date: 'Oct 13', fcr: 1.35, target: 1.40 }, { date: 'Oct 20', fcr: 1.33, target: 1.40 }, ]; // KPIs const kpis = [ { label: 'Predicted Weight (30 days)', value: '420g', change: '+47%', trend: 'up' }, { label: 'Forecasted FCR', value: '1.32', change: '-5%', trend: 'down' }, { label: 'Survival Rate Prediction', value: '96.8%', change: '+1.2%', trend: 'up' }, { label: 'Expected ROI', value: '42%', change: '+8%', trend: 'up' }, ]; // Scenario simulation results const scenarioResults = { currentFeed: { finalWeight: 420, fcr: 1.32, cost: 3250, profit: 14800 }, optimized: { finalWeight: 445, fcr: 1.28, cost: 3180, profit: 16200 } }; return (
Data-driven insights for optimal performance
Predictions based on historical data, water quality, and feeding patterns
Optimal Growth Trajectory
Current growth rate is 3% above predicted baseline. Fish are responding well to current feeding regime.
Harvest Window
Recommended harvest at 112 days (Week 16) when fish reach optimal market size of 650-700g.
Growth Acceleration Opportunity
Increasing feed protein content by 2% could improve SGR by 0.3% with minimal cost increase.
Predictions are updated every 6 hours based on real-time sensor data and growth sampling.
Above industry average (28%)
14 days ahead of schedule
Simulate different conditions to optimize your operations
Excellent performance
Low environmental impact