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

type ElementProps = {
  text: string;
};

type LinkProps = BaseButtonProps & ElementProps;

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