"use client"; import * as React from "react"; import { useSortable } from "@dnd-kit/sortable"; import { CSS } from "@dnd-kit/utilities"; import { Calendar, GripVertical } from "lucide-react"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Badge } from "@/components/ui/badge"; import type { ViewObject } from "@/lib/hooks/use-view-data"; import { usePanelStore } from "@/lib/stores/panel-store"; import { cn } from "@/lib/utils"; function getPriorityValue(object: ViewObject): string { const v = object.propertyValues?.find( (p) => p.propertyDefinition.name === "Priority", )?.value; return typeof v === "string" ? v : "—"; } function getDueDateValue(object: ViewObject): string { const v = object.propertyValues?.find( (p) => p.propertyDefinition.name === "Due Date", )?.value; return typeof v === "string" ? v : "—"; } function formatDueDisplay(iso: string): string { if (iso === "—") return ""; try { const d = new Date(iso); if (Number.isNaN(d.getTime())) return iso; return d.toLocaleDateString(undefined, { month: "short", day: "numeric", }); } catch { return iso; } } function priorityTone(p: string): string { switch (p) { case "High": return "border-destructive/40 bg-destructive/10 text-destructive"; case "Medium": return "border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-400"; case "Low": return "border-muted-foreground/30 bg-muted/80 text-muted-foreground"; default: return "border-border bg-muted/50 text-muted-foreground"; } } function initials(name: string | null): string { return (name ?? "?") .split(/\s+/) .map((p) => p[0]) .join("") .slice(0, 2) .toUpperCase(); } function CardMeta({ object }: { object: ViewObject }) { const openDetail = usePanelStore((s) => s.open); const priority = getPriorityValue(object); const dueRaw = getDueDateValue(object); const due = formatDueDisplay(dueRaw); const assignees = object.assignees ?? []; const shown = assignees.slice(0, 3); const extra = assignees.length - shown.length; return (