import { useMemo } from 'react'
import { UseFormReturn } from 'react-hook-form'
import { CloudProvider } from 'shared-data'
import {
cn,
FormField,
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
useWatch,
} from 'ui'
import { ComputeBadge } from 'ui-patterns/ComputeBadge'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { HIGH_AVAILABILITY_INSTANCE_SIZE, sizes } from './ProjectCreation.constants'
import { CreateProjectForm } from './ProjectCreation.schema'
import { InlineLink } from '@/components/ui/InlineLink'
import Panel from '@/components/ui/Panel'
import { instanceSizeSpecs } from '@/data/projects/new-project.constants'
import { DOCS_URL } from '@/lib/constants'
interface ComputeSizeSelectorProps {
form: UseFormReturn
}
export const ComputeSizeSelector = ({ form }: ComputeSizeSelectorProps) => {
const cloudProvider = useWatch({ control: form.control, name: 'cloudProvider' }) as CloudProvider
const highAvailability = useWatch({ control: form.control, name: 'highAvailability' })
const sizeOptions = useMemo(
() =>
highAvailability
? [HIGH_AVAILABILITY_INSTANCE_SIZE]
: sizes.filter((option) =>
instanceSizeSpecs[option].cloud_providers.includes(cloudProvider)
),
[highAvailability, cloudProvider]
)
return (
(
The size for your dedicated database. You can change this later. Learn more about{' '}
compute add-ons
{' '}
and{' '}
compute billing
.
}
>
)}
/>
)
}