CreateFunctionConfigParamsSection.tsx 907 B

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