import type { BaseElementProps } from './types';
import { Button as AntButton } from 'antd';
import type { BaseButtonProps } from 'antd/lib/button/button';
import type { FC } from 'react';

type ElementProps = {
  text: string;
};

type LinkProps = BaseButtonProps & ElementProps;

function Link({ value, status, text, ...props }: BaseElementProps<string> & ElementProps) {
  return (
    <AntButton
      disabled={status === 'Disabled' || !value}
      href={value}
      loading={status === 'Loading'}
      rel="noopener"
      target="_blank"
      {...props}
    >
      {text}
    </AntButton>
  );
}

export default Link as FC<LinkProps>;
