Skip to content

Instantly share code, notes, and snippets.

@kimniche
Last active June 20, 2018 17:30
Show Gist options
  • Save kimniche/2c85138793f60a7b5a9ecee891c0fd3b to your computer and use it in GitHub Desktop.
Save kimniche/2c85138793f60a7b5a9ecee891c0fd3b to your computer and use it in GitHub Desktop.

To support adding a conditional link to the user dropdown - these are just my loose notes, any dev picking this up please feel free to do whatever works best for you

  • For logged in users dropdown, logged out dropdown will be unaffected

Current implementation

Loose plan

Gather user demographics from store and pass (as demographics key, so we can later pass other objects by name) into function defined on the user-logged-in.js list entry that determines whether or not the link can show, maybe something like function canDisplay({ demographics }) that just returns a boolean?

  • Lets us re-use this approach to conditionally render other links in this dropdown, even if they require other data (BP?), in the future

Loose steps

  • migrate buildURL functionality out of GlobalAccountUserLink.jsx and into the links themselves
  • make GlobalAccountUser.jsx fetch user demographics from UserStore
  • add check within map function in GlobalAccountUser.jsx to call canDisplay with demographics data and only return the GlobalAccountUserLink when appropriate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment