import { InsertPosition } from '@/components';
import { Access, useAccess } from '@umijs/max';
import { Button, ButtonProps } from 'antd';
import React from 'react';

interface ButtonAccessProps extends ButtonProps {
	permission: string;
	positionKey?: string;
	insertPosition?: InsertPosition;
}

const ButtonAccess: React.FC<ButtonAccessProps> = (props) => {
	// eslint-disable-next-line @typescript-eslint/no-unused-vars
	const { permission, positionKey, insertPosition, ...rest } = props;
	return (
		<Access accessible={useAccess().permission(permission)}>
			<Button size={'small'} {...rest} />
		</Access>
	);
};

export default ButtonAccess;
