import { useParams } from 'common' import Link from 'next/link' import { UseFormReturn } from 'react-hook-form' import { Button, FormControl, FormField, Input, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, useWatch, } from 'ui' import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' import { WebhookFormValues } from './EditHookPanel.constants' import { FormSection, FormSectionContent, FormSectionLabel, } from '@/components/ui/Forms/FormSection' import { useEdgeFunctionsQuery } from '@/data/edge-functions/edge-functions-query' import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject' import { buildDatabaseEdgeFunctionUrl } from '@/lib/api/edgeFunctions' interface HTTPRequestConfigProps { form: UseFormReturn } export const HTTPRequestConfig = ({ form }: HTTPRequestConfigProps) => { const { ref } = useParams() const { data: selectedProject } = useSelectedProjectQuery() const { data: functions } = useEdgeFunctionsQuery({ projectRef: ref }) const edgeFunctions = functions ?? [] const functionType = useWatch({ control: form.control, name: 'function_type' }) return ( {functionType === 'http_request' ? 'HTTP Request' : functionType === 'supabase_function' ? 'Edge Function' : ''} } > ( )} /> {functionType === 'http_request' ? ( ( )} /> ) : functionType === 'supabase_function' && edgeFunctions.length === 0 ? (

Select which edge function to trigger

No edge functions created yet

) : functionType === 'supabase_function' && edgeFunctions.length > 0 ? ( ( )} /> ) : null} (
ms
)} />
) }