mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-13 16:41:34 +08:00

* chore: arrow-body-style func-style is added in the rule * fix: linting issues fixed Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
22 lines
589 B
TypeScript
22 lines
589 B
TypeScript
import { useCallback, useMemo } from 'react';
|
|
import { ROLES } from 'types/roles';
|
|
import { componentPermission, ComponentTypes } from 'utils/permission';
|
|
|
|
const useComponentPermission = (
|
|
component: ComponentTypes[],
|
|
role: ROLES | null,
|
|
): boolean[] => {
|
|
const getComponentPermission = useCallback(
|
|
(component: ComponentTypes): boolean =>
|
|
!!componentPermission[component].find((roles) => role === roles),
|
|
[role],
|
|
);
|
|
|
|
return useMemo(() => component.map((e) => getComponentPermission(e)), [
|
|
component,
|
|
getComponentPermission,
|
|
]);
|
|
};
|
|
|
|
export default useComponentPermission;
|