/*
 * @Note:
 * @Author: 2058827620@qq.com
 * @Date: 2022-04-03 10:53:25
 */
import { useModel } from 'umi';

export const AuthConsumer = (props) => {
  const { initialState, loading, error, refresh, setInitialState } = useModel('@@initialState');

  const auth = initialState?.authPermissionAction;

  if (!auth) {
    return <span>{props.children}</span>;
  }
  const res = auth.indexOf(props.action);
  return res >= 0 ? <span>{props.children}</span> : <></>;
};

export default AuthConsumer;
