import { useState } from 'react' import { X } from 'lucide-react' import { cn } from '@/lib/utils' interface CreateCategoryModalProps { isOpen: boolean onClose: () => void onSubmit: (data: { name: string; description: string }) => Promise isSaving?: boolean } export function CreateCategoryModal({ isOpen, onClose, onSubmit, isSaving = false }: CreateCategoryModalProps) { const [name, setName] = useState('') const [description, setDescription] = useState('') const [error, setError] = useState('') if (!isOpen) return null const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError('') if (!name.trim()) { setError('Category name is required') return } if (name.length > 100) { setError('Category name must be 100 characters or less') return } try { await onSubmit({ name: name.trim(), description: description.trim() }) // Reset form on success setName('') setDescription('') } catch { setError('Failed to create category') } } const handleClose = () => { if (!isSaving) { setName('') setDescription('') setError('') onClose() } } return (
{/* Header */}

Create Category

{/* Form */}
{/* Error Message */} {error && (
{error}
)} {/* Name Field */}
setName(e.target.value)} disabled={isSaving} maxLength={100} placeholder="e.g., Network Troubleshooting" required className={cn( 'w-full rounded-md border border-border bg-card px-3 py-2 text-sm text-foreground', 'placeholder:text-muted-foreground', 'focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary/20', 'disabled:opacity-50' )} />

{name.length}/100 characters

{/* Description Field */}