'use client'; import { useState } from "react"; export enum FieldType { number = 'number', text = 'text' } export type FormFields = { type: FieldType, name: string, label: string, required: boolean } const Form = ({ fields, onSubmit }) => { const [formData, setFormData] = useState({}); const handleChange = (event) => { const { name, value } = event.target; setFormData( (prevData) => ({ ...prevData, [name]: value })); } const handleSubmit = (event) => { event.preventDefault(); onSubmit( formData ); } return (
{fields.map( (field) => { return (
)})}
); } export default Form;