HighAvailabilityInput.tsx44 lines · main
1import Link from 'next/link'
2import { UseFormReturn } from 'react-hook-form'
3import { FormControl, FormField, Switch } from 'ui'
4import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
5
6import { CreateProjectForm } from './ProjectCreation.schema'
7import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
8
9interface HighAvailabilityInputProps {
10 form: UseFormReturn<CreateProjectForm>
11}
12
13export const HighAvailabilityInput = ({ form }: HighAvailabilityInputProps) => {
14 const { hasAccess } = useCheckEntitlements('instances.high_availability')
15
16 if (!hasAccess) return null
17
18 return (
19 <FormField
20 control={form.control}
21 name="highAvailability"
22 render={({ field }) => (
23 <FormItemLayout
24 label="High Availability"
25 description={
26 <>
27 Powered by{' '}
28 <Link href="https://multigres.com/" target="_blank" className="text-link">
29 Multigres
30 </Link>
31 : horizontally scalable Postgres for multi-tenant, highly available, globally
32 distributed deployments while staying true to standard Postgres.
33 </>
34 }
35 layout="horizontal"
36 >
37 <FormControl>
38 <Switch checked={field.value} onCheckedChange={field.onChange} />
39 </FormControl>
40 </FormItemLayout>
41 )}
42 />
43 )
44}