import { useState } from "react"; import { Icon } from "./icon"; interface FormField { name: string; label: string; type: "text" | "textarea" | "number" | "select" | "checkbox" | "code"; value: string | number | boolean; options?: { value: string; label: string }[]; placeholder?: string; required?: boolean; rows?: number; } interface MobileEditViewProps { title: string; fields?: FormField[]; onSave: (data: Record) => void; onCancel: () => void; isSaving?: boolean; children?: React.ReactNode; } export const MobileEditView: React.FC = ({ title, fields, onSave, onCancel, isSaving = false, children, }) => { const [formData, setFormData] = useState>( () => { const initial: Record = {}; fields?.forEach((field) => { initial[field.name] = field.value; }); return initial; } ); const handleChange = (name: string, value: string | number | boolean) => { setFormData((prev) => ({ ...prev, [name]: value })); }; const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); onSave(formData); }; return (

{title}

{children || fields?.map((field) => (
{field.type === "textarea" && (