"use client"; import { useState } from "react"; import type { ClientView } from "@/lib/client-view"; import type { Comment } from "@/db/schema"; import { ApproveButton } from "@/components/client/ApproveButton"; import { CommentList } from "@/components/client/CommentList"; import { CommentForm } from "@/components/client/CommentForm"; type Task = ClientView["phases"][number]["tasks"][number] & { phaseTitle: string; }; const COLUMNS: { id: "todo" | "in_progress" | "done"; label: string; dotClass: string; headerClass: string }[] = [ { id: "todo", label: "Da fare", dotClass: "bg-[#d4d4d8]", headerClass: "text-[#71717a]", }, { id: "in_progress", label: "In corso", dotClass: "bg-[#DEF168]", headerClass: "text-[#1A463C]", }, { id: "done", label: "Fatto", dotClass: "bg-[#1A463C]", headerClass: "text-[#1A463C]", }, ]; function TaskCard({ task, token, comments, }: { task: Task; token: string; comments: Comment[]; }) { const [expanded, setExpanded] = useState(false); const taskComments = comments.filter((c) => c.entity_id === task.id); const hasDeliverables = task.deliverables.length > 0; const hasActivity = taskComments.length > 0 || hasDeliverables; return (
{expanded && (
{task.description && (

{task.description}

)} {hasDeliverables && (
{task.deliverables.map((d) => { const delivComments = comments.filter((c) => c.entity_id === d.id); return (
{d.title} {(d.status === "pending" || d.status === "submitted" || d.approved_at !== null) && ( )}
); })}
)}
)}
); } export function ClientKanban({ phases, token, comments, }: { phases: ClientView["phases"]; token: string; comments: Comment[]; }) { const allTasks: Task[] = phases.flatMap((phase) => phase.tasks.map((task) => ({ ...task, phaseTitle: phase.title })) ); const tasksByStatus = { todo: allTasks.filter((t) => t.status === "todo"), in_progress: allTasks.filter((t) => t.status === "in_progress"), done: allTasks.filter((t) => t.status === "done"), }; return (
{COLUMNS.map((col) => (
{col.label}
{tasksByStatus[col.id].length}
{tasksByStatus[col.id].map((task) => ( ))} {tasksByStatus[col.id].length === 0 && (

Nessun task

)}
))}
); }