import React from 'react';
import { View } from '@tarojs/components';
import { useModel } from '@/store';

export default (props) => {
  const { roles = [] } = props;
  const { duty } = useModel('user');

  const hasRights = roles.indexOf(duty) > -1;

  return !roles.length || hasRights ? props.children : (
    <View style={{width: '100%', height: '100%', display: 'grid', placeItems: 'center'}}>
      <View>暂无权限</View>
    </View>
  );
}
