"use client"; import { Check, Plus } from "lucide-react"; import { type FormEvent, type ReactNode, useMemo, useState } from "react"; import { TaskDetailSheet } from "@/components/tasks/task-detail-sheet"; 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 { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; 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. export type Priority = "high" | "medium" | "low"; export 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 [notes, setNotes] = useState(""); const [assignee, setAssignee] = useState(""); const [due, setDue] = useState(""); const [priority, setPriority] = useState("medium"); const reset = () => { setTitle(""); setNotes(""); setAssignee(""); setDue(""); setPriority("medium"); }; const submit = (event: FormEvent) => { event.preventDefault(); if (!title.trim()) { notify.error("Add a subject", "Describe the task first."); return; } onAdd({ title: title.trim(), notes: notes.trim() || undefined, 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} />