import React from 'react'
import { Role, Permission, hasPermission, isInRole } from '../../utils/PermissionService'

type PrivateContentProps = {
    roles?: Role[] | Role
    permission?: Permission
    children?: React.ReactElement<any, any>
}

export const PrivateContent: React.FC<PrivateContentProps> = ({ permission, roles, children = null }) =>
    hasPermission(permission) || isInRole(roles) ? children : null
