import React, { useState } from 'react';
import { Popconfirm, Button } from 'antd';
import { useModel } from '@umijs/max';

function PremButton(props) {
  const { initialState, setInitialState } = useModel('@@initialState');
  const { children, btn, pop, access } = props;
  let accesses = access ? ['havePrem'].includes(access) : true;
  //配置按钮权限接口

  return pop ? (
    <Popconfirm {...pop} disabled={pop?.disabled || !accesses}>
      <Button {...btn} disabled={btn?.disabled || !accesses}>
        {children}
      </Button>
    </Popconfirm>
  ) : (
    <Button {...btn} disabled={btn?.disabled || !accesses}>
      {children}
    </Button>
  );
}

export default PremButton;
