import type { CommonProps } from '@/proxy/common'
import { usePermission } from '@/utils/hooks/usePermission'

interface PermissionCheckProps extends CommonProps {
  permissions: string[]
}

const PermissionCheck = (props: PermissionCheckProps) => {
  const { permissions = [], children } = props

  const { checkPermissions } = usePermission()
  const permissionsMatched = checkPermissions(permissions)

  return <>{permissionsMatched ? children : null}</>
}

export default PermissionCheck
