import { useState } from 'react'; import { array, object, SchemaOf, string } from 'yup'; import { ArrayError } from '../InputList/InputList'; import { AdvancedMode } from './AdvancedMode'; import { SimpleMode } from './SimpleMode'; import { Value } from './types'; export function EnvironmentVariablesFieldset({ onChange, values, errors, }: { values: Value; onChange(value: Value): void; errors?: ArrayError; }) { const [simpleMode, setSimpleMode] = useState(true); return (
{simpleMode ? ( setSimpleMode(false)} onChange={onChange} value={values} errors={errors} /> ) : ( setSimpleMode(true)} onChange={onChange} value={values} /> )}
); } export function envVarValidation(): SchemaOf { return array( object({ name: string().required('Name is required'), value: string().default(''), }) ); }