Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New hook usePermissions() #17

Open
santospatrick opened this issue Sep 3, 2022 · 0 comments
Open

New hook usePermissions() #17

santospatrick opened this issue Sep 3, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@santospatrick
Copy link
Owner

santospatrick commented Sep 3, 2022

Is your feature request related to a problem? Please describe.
Getting user permissions require some coding, which may duplicate code with time.

Describe the solution you'd like
Create a hook usePermissions() which should return an array of logged in user permissions.

// to avoid this
const { user } = useContext(AuthContext);
const { data } = useQuery(
  "user-profiles",
  () => api.get(`users/${user?.id}`),
  {
    enabled: !!user?.id,
  }
);
console.log("profiles ==> ", data?.data.profiles);

Describe alternatives you've considered
Solution would be:

// 🚀
const permissions = usePermissions();
console.log("profiles ==> ", permissions);

Additional context
No.

@santospatrick santospatrick added the enhancement New feature or request label Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant