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

type ElementProps = {
  text: string;
};

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

type LinkProps = BaseButtonProps & ElementProps;

export type { LinkProps };
