Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

974 B
Raw Blame
import { IS_PLATFORM } from 'common'
import type { CommandOptions } from 'ui-patterns/CommandMenu'
import { useRegisterCommands } from 'ui-patterns/CommandMenu'

import { COMMAND_MENU_SECTIONS } from '@/components/interfaces/App/CommandMenu/CommandMenu.utils'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'

export function useBillingGotoCommands(options?: CommandOptions) {
  const { data: organization } = useSelectedOrganizationQuery()
  const billingEnabled = useIsFeatureEnabled('billing:all')
  const slug = organization?.slug ?? '_'

  useRegisterCommands(
    COMMAND_MENU_SECTIONS.NAVIGATE,
    IS_PLATFORM && billingEnabled
      ? [
          {
            id: 'nav-billing',
            name: 'Billing',
            route: `/org/${slug}/billing`,
            defaultHidden: true,
          },
        ]
      : [],
    { ...options, deps: [slug] }
  )
}