HighAvailabilityInput.tsx 1.4 KB

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