Files
supabase/apps/studio/components/interfaces/Integrations/CronJobs/SqlFunctionSection.tsx
T
Terry Sutton b6de81485c new Integrations page (#29671)
* Start new integrations page

* Move cronjobs into integrations

* Rearrange

* Remove duplicate

* Move around menu items
2024-10-22 09:39:36 -02:30

53 lines
1.6 KiB
TypeScript

import { UseFormReturn } from 'react-hook-form'
import FunctionSelector from 'components/ui/FunctionSelector'
import SchemaSelector from 'components/ui/SchemaSelector'
import { FormField_Shadcn_, SheetSection } from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { CreateCronJobForm } from './CreateCronJobSheet'
interface SqlFunctionSectionProps {
form: UseFormReturn<CreateCronJobForm>
}
export const SqlFunctionSection = ({ form }: SqlFunctionSectionProps) => {
const schema = form.watch('values.schema')
return (
<SheetSection className="flex flex-col gap-3">
<FormField_Shadcn_
control={form.control}
name="values.schema"
render={({ field }) => (
<FormItemLayout label="Schema" className="gap-1">
<SchemaSelector
size="small"
selectedSchemaName={field.value}
onSelectSchema={(name) => {
field.onChange(name)
// deselect the selected function when the schema is changed
form.resetField('values.functionName')
}}
/>
</FormItemLayout>
)}
/>
<FormField_Shadcn_
control={form.control}
name="values.functionName"
render={({ field }) => (
<FormItemLayout label="Function name" className="gap-1">
<FunctionSelector
size="small"
schema={schema}
value={field.value}
onChange={(name) => field.onChange(name)}
/>
</FormItemLayout>
)}
/>
</SheetSection>
)
}