HTTPParameters.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { UseFormReturn } from 'react-hook-form'
  2. import { KeyValueFieldArray } from 'ui-patterns/form/KeyValueFieldArray/KeyValueFieldArray'
  3. import { WebhookFormValues } from './EditHookPanel.constants'
  4. import {
  5. FormSection,
  6. FormSectionContent,
  7. FormSectionLabel,
  8. } from '@/components/ui/Forms/FormSection'
  9. import { uuidv4 } from '@/lib/helpers'
  10. interface HTTPParametersProps {
  11. form: UseFormReturn<WebhookFormValues>
  12. }
  13. export const HTTPParameters = ({ form }: HTTPParametersProps) => {
  14. return (
  15. <FormSection
  16. header={<FormSectionLabel className="lg:col-span-4!">HTTP Parameters</FormSectionLabel>}
  17. >
  18. <FormSectionContent loading={false} className="lg:col-span-8!">
  19. <KeyValueFieldArray
  20. control={form.control}
  21. name="httpParameters"
  22. keyFieldName="name"
  23. valueFieldName="value"
  24. createEmptyRow={() => ({ id: uuidv4(), name: '', value: '' })}
  25. keyPlaceholder="Parameter name"
  26. valuePlaceholder="Parameter value"
  27. addLabel="Add a new parameter"
  28. removeLabel="Remove parameter"
  29. />
  30. </FormSectionContent>
  31. </FormSection>
  32. )
  33. }