'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import { ChevronLeft, ClipboardList, Clock, User, AlertCircle } from 'lucide-react' import { Card, Button, showToast } from '@/components/ui' import { Header, PageContainer } from '@/components/layout/header' import { useApp } from '../../provider' const PRIORITIES = [ { value: 'LOW', label: 'Low', color: 'bg-blue-100 text-blue-700' }, { value: 'MEDIUM', label: 'Medium', color: 'bg-yellow-100 text-yellow-700' }, { value: 'HIGH', label: 'High', color: 'bg-orange-100 text-orange-700' }, { value: 'URGENT', label: 'Urgent', color: 'bg-red-100 text-red-700' }, ] const CATEGORIES = [ { value: 'GENERAL', label: 'General', emoji: '📝' }, { value: 'MEDICATION', label: 'Medication', emoji: '💊' }, { value: 'APPOINTMENT', label: 'Appointment', emoji: '📅' }, { value: 'SYMPTOM', label: 'Symptom', emoji: '😷' }, ] export default function NewCareTaskPage() { const router = useRouter() const { currentWorkspace } = useApp() const [title, setTitle] = useState('') const [description, setDescription] = useState('') const [priority, setPriority] = useState('MEDIUM') const [category, setCategory] = useState('GENERAL') const [dueDate, setDueDate] = useState('') const [saving, setSaving] = useState(false) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() if (!title.trim()) { showToast('Please enter a task title', 'error') return } setSaving(true) try { const response = await fetch(`/api/workspaces/${currentWorkspace.id}/care-tasks`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title: title.trim(), description: description.trim() || null, priority, category, dueAt: dueDate ? new Date(dueDate).toISOString() : null, }), }) if (!response.ok) throw new Error('Failed to create task') showToast('Task created!', 'success') router.push('/care') } catch { showToast('Failed to create task', 'error') } finally { setSaving(false) } } return ( <>
, label: 'Back', onClick: () => router.push('/care') }} />
{/* Title */} setTitle(e.target.value)} placeholder="e.g., Pick up prescription" className="w-full px-3 py-2 border border-border rounded-lg text-base focus:outline-none focus:ring-2 focus:ring-primary-200 focus:border-primary-500" required /> {/* Category */}
{CATEGORIES.map((cat) => ( ))}
{/* Priority */}
{PRIORITIES.map((p) => ( ))}
{/* Due Date */} setDueDate(e.target.value)} className="w-full px-3 py-2 border border-border rounded-lg text-base focus:outline-none focus:ring-2 focus:ring-primary-200 focus:border-primary-500" /> {/* Description */}