2021-12-07 19:45:13 +05:00
|
|
|
import React from 'react'
|
2021-12-15 11:01:18 +05:00
|
|
|
import { Role, Permission, hasPermission, isInRole } from '../../utils/PermissionService'
|
2021-12-02 15:10:55 +05:00
|
|
|
|
|
|
|
type PrivateContentProps = {
|
2021-12-15 11:01:18 +05:00
|
|
|
roles?: Role[] | Role
|
|
|
|
permission?: Permission
|
|
|
|
children?: React.ReactElement<any, any>
|
2021-12-02 15:10:55 +05:00
|
|
|
}
|
|
|
|
|
2021-12-15 11:01:18 +05:00
|
|
|
export const PrivateContent: React.FC<PrivateContentProps> = ({ permission, roles, children = null }) =>
|
|
|
|
hasPermission(permission) || isInRole(roles) ? children : null
|