import React, { useMemo } from 'react';

import { Result } from 'antd';

import check from './CheckPermissions';
// <Result
//   status="403"
//   title="403"
//   subTitle="Sorry, you are not authorized to access this page."
// />
const Authorized = ({
  children,
  authority,
  flatMenu,
  updateAuthValidate,
  global,
  noMatch = <div />,
}) => {
  const childrenRender = typeof children === 'undefined' ? null : children;

  const auth = useMemo(
    () => check(authority, flatMenu, childrenRender, noMatch),
    [],
  );
  // 目前写死
  // const basePath = 'civweb4';

  // updateAuthValidate && updateAuthValidate(auth.validate);
  return <>{auth.target}</>;
};

export default Authorized;