Sana Assistant (online)
Table of Contents

UseHasAbilities hook

const hasAbilities = useHasAbilities();

The useHasAbilities hook provides info about current user abilities. This hook returns the evaluated user abilities by specified keys. It will return an empty array if ability keys are not passed as function arguments.

The list of possible ability keys:

  • 'VIEW_CATALOG'
  • 'VIEW_PRICES'
  • 'VIEW_STOCK'
  • 'VIEW_UNIT_OF_MEASURE'
  • 'ORDER_PRODUCTS'
  • 'USE_CHECKOUT_ITEM_LINE_COMMENTS'

Example:

const [canViewStock, canViewCatalog] = useHasAbilities('VIEW_CATALOG', 'VIEW_STOCK');