"use client"; import { Card, CardContent, CardHeader, CardFooter } from "@/components/ui/card"; import { MapPin, Sprout, Plus, ArrowRight, MoreVertical, Edit, Trash2 } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import type { Farm } from "@/types"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; export interface FarmCardProps { variant: "farm" | "add"; farm?: Farm; // Use updated Farm type onClick?: () => void; onEditClick?: (e: React.MouseEvent) => void; // Callback for edit onDeleteClick?: (e: React.MouseEvent) => void; // Callback for delete } export function FarmCard({ variant, farm, onClick, onEditClick, onDeleteClick }: FarmCardProps) { const cardClasses = cn( "w-full h-full overflow-hidden transition-all duration-200 hover:shadow-lg border", variant === "add" ? "bg-green-50/50 dark:bg-green-900/50 hover:bg-green-50/80 dark:hover:bg-green-900/80 border-dashed border-muted/60" : "bg-white dark:bg-slate-800 hover:bg-muted/10 dark:hover:bg-slate-700 border-muted/60" ); // Stop propagation for dropdown menu trigger and items const stopPropagation = (e: React.MouseEvent) => { e.stopPropagation(); }; if (variant === "add") { return (

Add New Farm

Create a new farm to manage your crops and resources

); } if (variant === "farm" && farm) { // const formattedDate = new Intl.DateTimeFormat("en-US", { // year: "numeric", // month: "short", // day: "numeric", // }).format(new Date(farm.createdAt)); return (
{farm.farmType} {/* Actions Dropdown */} Edit Farm Delete Farm
{/* Use div for clickable area if needed, or rely on button */}
{/* Ensure text truncates */}

{farm.name}

{/* Display truncated location or just Lat/Lon */} Lat: {farm.lat.toFixed(3)}, Lon: {farm.lon.toFixed(3)}

Area

{farm.totalSize || "N/A"}

Crops

{farm.crops ? farm.crops.length : 0}

{" "} {/* Keep footer outside clickable area */}
); } return null; }