Billing.Commands.tsx28 lines · main
| 1 | import { IS_PLATFORM } from 'common' |
| 2 | import type { CommandOptions } from 'ui-patterns/CommandMenu' |
| 3 | import { useRegisterCommands } from 'ui-patterns/CommandMenu' |
| 4 | |
| 5 | import { COMMAND_MENU_SECTIONS } from '@/components/interfaces/App/CommandMenu/CommandMenu.utils' |
| 6 | import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled' |
| 7 | import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization' |
| 8 | |
| 9 | export 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 | } |