Community Health Toolkit

Context : 'user.role === "chw" ' is not working in targets

Describe the Bug
Upon adding context : 'user.role === “chw” ’ in targets.js that target is not showing up on UI.

How To Reproduce The Issue
List steps for someone trying to reproduce the behavior. For example:

  1. Add context : 'user.role === “chw” ’ in any one of the target goal/case and update app_settings
  2. Login as chw user and Go to ‘targets’
  3. Click on ‘targets’
  4. Observe the target is not showing up in targets but when context : 'user.role === “chw” ’ is not working in targets is removed and updated that target is showing up in targets.
  5. No error is showing up on UI.

Note: Provided user role as same in both app_settings and context.

Environment

  • Instance: (eg: localhost etc)
  • Browser: (eg: Chrome)
  • Client platform: (eg: Windows)
  • App: (eg: webapp)
  • Version: (3.10.1, etc)

The definition of the user object can change across projects depending on how you define your hierarchy.

If you add a statement like console.log(user); into the top of the target.js file, you can compile and deploy that change to view the user object in chrome’s dev console. What does your user object look like? Does it have a role attribute?

You can add information to this object by altering your contact forms. Or you can use the information that is already there. Is the user’s position in the hierarchy a reliable indicator of their role? If so, consider something like isChw = () => user.parent.contact_type === 'chw_area'

Thanks for the quick reply Kenn .Will try the above method.