Billing.Commands.tsx28 lines · main
1import { IS_PLATFORM } from 'common'
2import type { CommandOptions } from 'ui-patterns/CommandMenu'
3import { useRegisterCommands } from 'ui-patterns/CommandMenu'
4
5import { COMMAND_MENU_SECTIONS } from '@/components/interfaces/App/CommandMenu/CommandMenu.utils'
6import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
7import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
8
9export function useBillingGotoCommands(options?: CommandOptions) {
10 const { data: organization } = useSelectedOrganizationQuery()
11 const billingEnabled = useIsFeatureEnabled('billing:all')
12 const slug = organization?.slug ?? '_'
13
14 useRegisterCommands(
15 COMMAND_MENU_SECTIONS.NAVIGATE,
16 IS_PLATFORM && billingEnabled
17 ? [
18 {
19 id: 'nav-billing',
20 name: 'Billing',
21 route: `/org/${slug}/billing`,
22 defaultHidden: true,
23 },
24 ]
25 : [],
26 { ...options, deps: [slug] }
27 )
28}