'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import { ChevronLeft, MessageSquare, AlertCircle, Users } from 'lucide-react' import { addHours } from 'date-fns' import { Card, Button, showToast } from '@/components/ui' import { Header, PageContainer } from '@/components/layout/header' import { useApp } from '../../provider' const CATEGORIES = [ { value: 'GENERAL', label: 'General Update', emoji: 'š', color: 'bg-blue-100 border-blue-200' }, { value: 'SYMPTOM', label: 'Symptom Observation', emoji: 'š·', color: 'bg-red-50 border-red-200' }, { value: 'MEDICATION', label: 'Medication Note', emoji: 'š', color: 'bg-green-50 border-green-200' }, { value: 'MOOD', label: 'Mood/Energy', emoji: 'š', color: 'bg-purple-50 border-purple-200' }, ] const PRIORITIES = [ { value: 'LOW', label: 'FYI Only' }, { value: 'NORMAL', label: 'Normal' }, { value: 'HIGH', label: 'Important - Please Read', color: 'text-red-600' }, ] export default function NewHandoffNotePage() { const router = useRouter() const { currentWorkspace } = useApp() const [content, setContent] = useState('') const [category, setCategory] = useState('GENERAL') const [priority, setPriority] = useState('NORMAL') const [expiresIn, setExpiresIn] = useState('12') const [saving, setSaving] = useState(false) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() if (!content.trim()) { showToast('Please write a note', 'error') return } setSaving(true) try { const expiresAt = addHours(new Date(), parseInt(expiresIn)) const response = await fetch(`/api/workspaces/${currentWorkspace.id}/handoff-notes`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ content: content.trim(), category, priority, expiresAt: expiresAt.toISOString(), }), }) if (!response.ok) throw new Error('Failed to create note') showToast('Handoff note added!', 'success') router.push('/care') } catch { showToast('Failed to add note', 'error') } finally { setSaving(false) } } return ( <> , label: 'Back', onClick: () => router.push('/care') }} /> {/* Info Card */} What are handoff notes? Use these to communicate with other caregivers. They expire after a set time and can be marked as read. {/* Category */} What type of note? {CATEGORIES.map((cat) => ( setCategory(cat.value)} className={`w-full p-3 rounded-lg border-2 text-left transition-all flex items-center gap-3 ${ category === cat.value ? cat.color + ' border-current' : 'border-border hover:border-secondary-300' }`} > {cat.emoji} {cat.label} ))} {/* Priority */} Priority setPriority(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" > {PRIORITIES.map((p) => ( {p.label} ))} {/* Content */} Your Note setContent(e.target.value)} placeholder="What should other caregivers know? For example:\n⢠Patient seemed more tired than usual today\n⢠New medication started, watching for side effects\n⢠Appointment went well, next one scheduled for..." rows={5} 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 resize-none" required /> {/* Expires In */} Note expires in {['4', '12', '24', '48'].map((hours) => ( setExpiresIn(hours)} className={`flex-1 py-2 rounded-lg border-2 text-sm font-medium transition-all ${ expiresIn === hours ? 'border-primary-500 bg-primary-50 text-primary-700' : 'border-border hover:border-secondary-300 text-secondary-600' }`} > {hours}h ))} Notes expire automatically to keep information fresh {/* Submit */} router.push('/care')} fullWidth > Cancel Add Note > ) }
Use these to communicate with other caregivers. They expire after a set time and can be marked as read.
Notes expire automatically to keep information fresh