import { FormikErrors } from 'formik'; import { TemplateEnv } from '@/react/portainer/templates/app-templates/types'; import { FormControl } from '@@/form-components/FormControl'; import { Input, Select } from '@@/form-components/Input'; type Value = Record; export function EnvVarsFieldset({ onChange, options, value, errors, }: { options: Array; onChange: (value: Value) => void; value: Value; errors?: FormikErrors; }) { return ( <> {options.map((env, index) => ( handleChange(env.name, value)} errors={errors?.[index]} /> ))} ); function handleChange(name: string, envValue: string) { onChange({ ...value, [name]: envValue }); } } function Item({ onChange, option, value, errors, }: { option: TemplateEnv; value: string; onChange: (value: string) => void; errors?: FormikErrors; }) { return ( {option.select ? ( onChange(e.target.value)} disabled={option.preset} /> )} ); }