import { addPhase, addTask, updateTaskStatus, updatePhaseStatus, } from "@/app/admin/clients/[id]/actions"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import type { ClientFullDetail } from "@/lib/admin-queries"; type Props = { phases: ClientFullDetail["phases"]; clientId: string; }; const taskStatusOptions = [ { value: "todo", label: "Da fare" }, { value: "in_progress", label: "In corso" }, { value: "done", label: "Fatto" }, ]; const phaseStatusOptions = [ { value: "upcoming", label: "In arrivo" }, { value: "active", label: "Attiva" }, { value: "done", label: "Completata" }, ]; export async function PhasesTab({ phases, clientId }: Props) { return (
{/* Add phase form */}
{ "use server"; await addPhase(clientId, fd); }} className="flex gap-2" >
{/* Phases list */} {phases.length === 0 && (

Nessuna fase ancora.

)} {phases.map((phase) => (

{phase.title}

{ "use server"; await updatePhaseStatus( phase.id, clientId, fd.get("status") as string ); }} className="flex items-center gap-2" >
{/* Tasks */}
{phase.tasks.map((task) => (
{task.title}
{ "use server"; await updateTaskStatus( task.id, clientId, fd.get("status") as string ); }} className="flex items-center gap-1" >
))}
{/* Add task form */}
{ "use server"; await addTask(phase.id, clientId, fd); }} className="flex gap-2 mt-2" >
))}
); }