'use client' import { useState } from 'react' import { X } from 'lucide-react' import { Button } from '@/components/ui/button' import { useLanguage } from '@/lib/i18n' import type { PropertyType } from '@/lib/structured-views/types' import { PROPERTY_TYPES } from '@/lib/structured-views/types' import { cn } from '@/lib/utils' type AddPropertyDialogProps = { open: boolean onClose: () => void onSubmit: (name: string, type: PropertyType, options: string[]) => Promise } export function AddPropertyDialog({ open, onClose, onSubmit }: AddPropertyDialogProps) { const { t } = useLanguage() const [name, setName] = useState('') const [type, setType] = useState('text') const [optionsText, setOptionsText] = useState('') const [saving, setSaving] = useState(false) if (!open) return null const needsOptions = type === 'select' || type === 'multiselect' const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() const trimmed = name.trim() if (!trimmed) return const options = needsOptions ? optionsText.split('\n').map((l) => l.trim()).filter(Boolean) : [] if (needsOptions && options.length === 0) return setSaving(true) try { await onSubmit(trimmed, type, options) setName('') setType('text') setOptionsText('') onClose() } finally { setSaving(false) } } return (

{t('structuredViews.addPropertyTitle')}

{t('structuredViews.addPropertyHint')}

setName(e.target.value)} className="mt-1 w-full rounded-lg border border-border bg-background px-3 py-2 text-sm" autoFocus />
{PROPERTY_TYPES.map((pt) => ( ))}
{needsOptions && (