Skip to content

Commit

Permalink
feat: add use perfil
Browse files Browse the repository at this point in the history
  • Loading branch information
ialexanderbrito committed Nov 1, 2022
1 parent 445d2ca commit 811a1c0
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/hooks/usePerfil.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export function usePerfil() {
const storagedUser = JSON.parse(localStorage.getItem('@barber:user') || '{}');

function isBarbeiro() {
if (storagedUser) {
if (storagedUser.tipoUsuario?.authority === 'GERENCIADOR') {
return true;
}
}

return false;
}

function isCliente() {
if (storagedUser) {
if (
storagedUser.tipoUsuario?.authority === 'CLIENTE' ||
storagedUser.tipoUsuario?.authority === 'ADMINISTRADOR'
) {
return true;
}
}

return false;
}

function isAdmin() {
if (storagedUser) {
if (storagedUser.tipoUsuario?.authority === 'ADMINISTRADOR') {
return true;
}
}

return false;
}

return {
isBarbeiro: isBarbeiro(),
isCliente: isCliente(),
isAdmin: isAdmin(),
};
}

0 comments on commit 811a1c0

Please sign in to comment.