2022-03-15 09:33:28 +00:00
|
|
|
import { useState } from './useState';
|
2022-03-11 10:41:23 +00:00
|
|
|
|
|
|
|
export function useRole() {
|
2022-03-28 07:06:36 +00:00
|
|
|
function hasAny(roles) {
|
2022-03-15 09:33:28 +00:00
|
|
|
const { getRoles } = useState();
|
2022-03-28 07:06:36 +00:00
|
|
|
const roleStore = getRoles();
|
2022-03-11 10:41:23 +00:00
|
|
|
|
|
|
|
for (const role of roles) {
|
2022-03-15 09:33:28 +00:00
|
|
|
if (roleStore.value.indexOf(role) !== -1) return true;
|
2022-03-11 10:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
hasAny,
|
|
|
|
};
|
|
|
|
}
|
2022-03-15 09:33:28 +00:00
|
|
|
|