CreateFunctionConfigParamsSection.tsx28 lines · main
1import { useFormContext } from 'react-hook-form'
2import { KeyValueFieldArray } from 'ui-patterns/form/KeyValueFieldArray/KeyValueFieldArray'
3
4type CreateFunctionConfigParamsFormValues = {
5 config_params: Array<{ name: string; value: string }>
6}
7
8export const CreateFunctionConfigParamsSection = () => {
9 const form = useFormContext<CreateFunctionConfigParamsFormValues>()
10
11 return (
12 <>
13 <h5 className="text-base text-foreground">Configuration Parameters</h5>
14 <KeyValueFieldArray
15 control={form.control}
16 name="config_params"
17 keyFieldName="name"
18 valueFieldName="value"
19 createEmptyRow={() => ({ name: '', value: '' })}
20 keyPlaceholder="parameter_name"
21 valuePlaceholder="parameter_value"
22 addLabel="Add a new config"
23 removeLabel="Remove configuration parameter"
24 rowsClassName="space-y-2 pt-4"
25 />
26 </>
27 )
28}