import React, { useState } from 'react'; import { X, Plus } from 'lucide-react'; interface Props { isOpen: boolean; onClose: () => void; onConfirm: (fieldName: string, fieldType: 'text' | 'number' | 'checkbox', forAllBuildings: boolean) => void; section?: 'general' | 'construction' | 'engineering' | 'land' | 'management'; } export const AddCustomFieldModal: React.FC = ({ isOpen, onClose, onConfirm, section }) => { const [fieldName, setFieldName] = useState(''); const [fieldType, setFieldType] = useState<'text' | 'number' | 'checkbox'>('text'); const [forAllBuildings, setForAllBuildings] = useState(false); if (!isOpen) return null; const handleConfirm = () => { if (!fieldName.trim()) { alert('Введите название поля'); return; } onConfirm(fieldName.trim(), fieldType, forAllBuildings); setFieldName(''); setFieldType('text'); setForAllBuildings(false); onClose(); }; const handleClose = () => { setFieldName(''); setFieldType('text'); setForAllBuildings(false); onClose(); }; return (
e.stopPropagation()} > {/* Header */}

Добавить новое поле

Укажите название и тип поля

{/* Content */}
setFieldName(e.target.value)} placeholder="Например: Материал кровли" className="w-full p-3 bg-white border border-slate-300 rounded-xl text-sm font-medium text-slate-800 outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500" autoFocus onKeyDown={(e) => { if (e.key === 'Enter') { handleConfirm(); } }} />
{/* Footer */}
); };