import { useState, useRef, useEffect } from 'react' import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { cn } from '@/lib/utils' const NOTE_TYPES = [ 'Note', 'Project', 'Experiment', 'Responsibility', 'Procedure', 'Person', 'Event', 'Topic', ] as const export type NoteType = (typeof NOTE_TYPES)[number] interface CreateNoteDialogProps { open: boolean onClose: () => void onCreate: (title: string, type: NoteType) => void defaultType?: NoteType } export function CreateNoteDialog({ open, onClose, onCreate, defaultType }: CreateNoteDialogProps) { const [title, setTitle] = useState('') const [type, setType] = useState('Note') const inputRef = useRef(null) useEffect(() => { if (open) { setTitle('') setType(defaultType ?? 'Note') setTimeout(() => inputRef.current?.focus(), 50) } }, [open, defaultType]) const handleSubmit = (e: React.FormEvent) => { e.preventDefault() const trimmed = title.trim() if (!trimmed) return onCreate(trimmed, type) onClose() } return ( { if (!isOpen) onClose() }}> Create New Note
setTitle(e.target.value)} />
{NOTE_TYPES.map((t) => ( ))}
) }