@@ -2,7 +2,7 @@ import Link from 'next/link'
22import { useState } from 'react'
33
44import { getAddons } from 'components/interfaces/Billing/Subscription/Subscription.utils'
5- import { InfraInstanceSize } from 'components/interfaces/DiskManagement/DiskManagement.types '
5+ import { ProjectDetail } from 'data/projects/project-detail-query '
66import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
77import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
88import { ProjectAddonVariantMeta } from 'data/subscriptions/types'
@@ -22,27 +22,28 @@ const Row = ({ label, stat }: { label: string; stat: React.ReactNode | string })
2222}
2323
2424interface ComputeBadgeWrapperProps {
25- project : {
26- ref ?: string
27- organization_slug ?: string
28- cloud_provider ?: string
29- infra_compute_size ?: InfraInstanceSize
30- }
25+ slug ?: string
26+ projectRef ?: string
27+ cloudProvider ?: string
28+ computeSize ?: ProjectDetail [ 'infra_compute_size' ]
3129}
3230
33- export const ComputeBadgeWrapper = ( { project } : ComputeBadgeWrapperProps ) => {
31+ export const ComputeBadgeWrapper = ( {
32+ slug,
33+ projectRef,
34+ cloudProvider,
35+ computeSize,
36+ } : ComputeBadgeWrapperProps ) => {
3437 // handles the state of the hover card
3538 // once open it will fetch the addons
3639 const [ open , setOpenState ] = useState ( false )
3740
3841 // returns hardcoded values for infra
39- const cpuArchitecture = getCloudProviderArchitecture ( project . cloud_provider )
42+ const cpuArchitecture = getCloudProviderArchitecture ( cloudProvider )
4043
4144 // fetches addons
4245 const { data : addons , isLoading : isLoadingAddons } = useProjectAddonsQuery (
43- {
44- projectRef : project . ref ,
45- } ,
46+ { projectRef } ,
4647 { enabled : open }
4748 )
4849 const selectedAddons = addons ?. selected_addons ?? [ ]
@@ -51,7 +52,7 @@ export const ComputeBadgeWrapper = ({ project }: ComputeBadgeWrapperProps) => {
5152 const computeInstanceMeta = computeInstance ?. variant ?. meta
5253
5354 const meta = (
54- computeInstanceMeta === undefined && project . infra_compute_size === 'micro'
55+ computeInstanceMeta === undefined && computeSize === 'micro'
5556 ? INSTANCE_MICRO_SPECS
5657 : computeInstanceMeta
5758 ) as ProjectAddonVariantMeta
@@ -62,26 +63,24 @@ export const ComputeBadgeWrapper = ({ project }: ComputeBadgeWrapperProps) => {
6263
6364 const highestComputeAvailable = availableCompute ?. [ availableCompute . length - 1 ] . identifier
6465
65- const isHighestCompute =
66- project ?. infra_compute_size === highestComputeAvailable ?. replace ( 'ci_' , '' )
66+ const isHighestCompute = computeSize === highestComputeAvailable ?. replace ( 'ci_' , '' )
6767
6868 const { data, isLoading : isLoadingSubscriptions } = useOrgSubscriptionQuery (
69- { orgSlug : project ?. organization_slug } ,
69+ { orgSlug : slug } ,
7070 { enabled : open }
7171 )
7272
73- const isEligibleForFreeUpgrade =
74- data ?. plan . id !== 'free' && project ?. infra_compute_size === 'nano'
73+ const isEligibleForFreeUpgrade = data ?. plan . id !== 'free' && computeSize === 'nano'
7574
7675 const isLoading = isLoadingAddons || isLoadingSubscriptions
7776
78- if ( ! project ?. infra_compute_size ) return null
77+ if ( ! computeSize ) return null
7978
8079 return (
8180 < HoverCard onOpenChange = { ( ) => setOpenState ( ! open ) } openDelay = { 280 } >
8281 < HoverCardTrigger asChild className = "group" onClick = { ( e ) => e . stopPropagation ( ) } >
8382 < div >
84- < ComputeBadge infraComputeSize = { project . infra_compute_size } />
83+ < ComputeBadge infraComputeSize = { computeSize } />
8584 </ div >
8685 </ HoverCardTrigger >
8786 < HoverCardContent
@@ -94,7 +93,7 @@ export const ComputeBadgeWrapper = ({ project }: ComputeBadgeWrapperProps) => {
9493 < Separator />
9594 < div className = "p-3 px-5 flex flex-row gap-4" >
9695 < div >
97- < ComputeBadge infraComputeSize = { project ?. infra_compute_size } />
96+ < ComputeBadge infraComputeSize = { computeSize } />
9897 </ div >
9998 < div className = "flex flex-col gap-4" >
10099 { isLoading ? (
@@ -145,7 +144,7 @@ export const ComputeBadgeWrapper = ({ project }: ComputeBadgeWrapperProps) => {
145144 </ div >
146145 < div >
147146 < Button asChild type = "default" htmlType = "button" role = "button" >
148- < Link href = { `/project/${ project ?. ref } /settings/compute-and-disk` } >
147+ < Link href = { `/project/${ projectRef } /settings/compute-and-disk` } >
149148 Upgrade compute
150149 </ Link >
151150 </ Button >
0 commit comments