Billing.Commands.tsx 974 B

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