"use client"; import { Table, TableBody, TableHeader, TableRow, TableHead, TableCell } from "@/components/ui/table"; import { Card, CardHeader, CardTitle, CardDescription, CardContent } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; import { ArrowUpRight, ArrowDownRight } from "lucide-react"; import { IMarketData, ITrend } from "@/lib/marketData"; interface MarketPriceTableProps { marketData: IMarketData[]; isLoading: boolean; onSelectCrop: (crop: string) => void; } const getTrendColor = (trend: ITrend) => (trend.direction === "up" ? "text-green-600" : "text-red-600"); const getTrendIcon = (trend: ITrend) => trend.direction === "up" ? ( ) : ( ); export default function MarketPriceTable({ marketData, isLoading, onSelectCrop }: MarketPriceTableProps) { if (isLoading) { return ( Market Price Table Comprehensive price data across all markets and crops ); } return ( Market Price Table Comprehensive price data across all markets and crops Crop {marketData[0]?.marketPrices.map((market) => ( {market.market} ))} Average Recommended {marketData.map((crop) => ( onSelectCrop(crop.name)}> {crop.name} {crop.marketPrices.map((market) => ( ${market.price.toFixed(2)} {getTrendIcon(market.trend)} ))} ${crop.averagePrice.toFixed(2)} ${crop.recommendedPrice.toFixed(2)} ))} ); }