import { FC, useState } from "react"; import { TextField as InternalTextField, Grid, Box, IconButton, } from "@mui/material"; import { AddCircle as AddCircleIcon, RemoveCircle as RemoveCircleIcon, } from "@mui/icons-material"; import { colors, typography } from "../styles/theme"; const TextField: FC = (props) => { return ( ); }; type MultiValueFieldProps = { name: string; label: string; formState: Record; helperText?: string; }; export const MultiValueField: FC = ({ name, label, formState, helperText, }) => { const { darkMediumGray, mediumBlue, brightRed } = colors; const { body } = typography; const value = formState.values[name] || {}; const [fields, setFields] = useState(Object.entries(value)); const addField = () => { setFields([...fields, ["", ""]]); }; const removeField = (index: number) => { const newFields = [...fields]; newFields.splice(index, 1); setFields(newFields); }; const updateField = (index: number, position: number, value: any) => { const newFields = [...fields]; newFields[index][position] = value; setFields(newFields); // formState.values[name] = Object.fromEntries(newFields); // console.log(formState.values); }; return ( ); };