"use client"; import { Check, ListTodo, Plus } from "lucide-react"; import { type FormEvent, type ReactNode, useMemo, useState } from "react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Dialog, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogPanel, DialogPopup, DialogTitle, } from "@/components/ui/dialog"; import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, } from "@/components/ui/empty"; import { Input } from "@/components/ui/input"; import { notify } from "@/lib/toast"; import { cn } from "@/lib/utils"; // All tasks here are mock/placeholder data — there is no tasks backend. They // illustrate a care-team to-do board. type Priority = "high" | "medium" | "low"; type Task = { id: string; title: string; assignee: string; due: string; priority: Priority; patient?: string; notes?: string; done: boolean; }; type Filter = "all" | "open" | "done"; const priorityVariant: Record = { high: "destructive", medium: "secondary", low: "outline", }; const priorityLabel: Record = { high: "High", medium: "Medium", low: "Low", }; const seed: Task[] = [ { id: "1", title: "Review Amina Yusuf's lab results", assignee: "Dr. Okafor", due: "Today", priority: "high", patient: "Amina Yusuf · #10293", notes: "Lipid panel + HbA1c back. Decide whether to adjust the plan before her follow-up.", done: false, }, { id: "2", title: "Confirm Daniel Mensah's prior records import", assignee: "Reception", due: "Today", priority: "medium", patient: "Daniel Mensah · #10311", notes: "Check the import completed before tomorrow's 10:00 appointment.", done: false, }, { id: "3", title: "Call Carlos Rivera about expired statin", assignee: "Dr. Okafor", due: "Tomorrow", priority: "medium", patient: "Carlos Rivera · #10358", done: false, }, { id: "4", title: "Restock vaccination fridge log", assignee: "Care team", due: "Jun 8", priority: "low", done: true, }, ]; function CheckButton({ done, onClick, }: { done: boolean; onClick: () => void; }) { return ( ); } function Field({ label, children }: { label: string; children: ReactNode }) { return ( ); } const controlClass = "h-9 w-full rounded-3xl border border-transparent bg-input/50 px-3 text-sm text-foreground outline-none transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30"; function AddTaskDialog({ open, onOpenChange, onAdd, }: { open: boolean; onOpenChange: (open: boolean) => void; onAdd: (task: Omit) => void; }) { const [title, setTitle] = useState(""); const [assignee, setAssignee] = useState(""); const [due, setDue] = useState(""); const [priority, setPriority] = useState("medium"); const reset = () => { setTitle(""); setAssignee(""); setDue(""); setPriority("medium"); }; const submit = (event: FormEvent) => { event.preventDefault(); if (!title.trim()) { notify.error("Add a title", "Describe the task first."); return; } onAdd({ title: title.trim(), assignee: assignee.trim() || "Unassigned", due: due.trim() || "No due date", priority, }); notify.success("Task added", title.trim()); reset(); onOpenChange(false); }; return ( { onOpenChange(o); if (!o) reset(); }} open={open} > New task Assign a follow-up to the care team.
setTitle(e.target.value)} placeholder="e.g. Review lab results" value={title} />
setAssignee(e.target.value)} placeholder="e.g. Dr. Okafor" value={assignee} /> setDue(e.target.value)} placeholder="e.g. Today" value={due} />
}> Cancel
); } export function TasksView() { const [tasks, setTasks] = useState(seed); const [selectedId, setSelectedId] = useState(null); const [filter, setFilter] = useState("all"); const [addOpen, setAddOpen] = useState(false); const selected = tasks.find((t) => t.id === selectedId) ?? null; const visible = useMemo(() => { if (filter === "open") return tasks.filter((t) => !t.done); if (filter === "done") return tasks.filter((t) => t.done); return tasks; }, [tasks, filter]); const toggle = (id: string) => setTasks((prev) => prev.map((t) => (t.id === id ? { ...t, done: !t.done } : t)), ); const addTask = (task: Omit) => setTasks((prev) => [ { ...task, id: `t-${Date.now()}`, done: false }, ...prev, ]); return (
{/* Left: task list */} {/* Right: task detail or empty state */}
{selected ? (

{selected.title}

{priorityLabel[selected.priority]}
Status
{selected.done ? "Completed" : "Open"}
Assignee
{selected.assignee}
Due
{selected.due}
{selected.patient && ( <>
Patient
{selected.patient}
)}
{selected.notes && (

{selected.notes}

)}
) : (
No task selected Select a task to see its details, or create a new one.
)}
); }