import Button from '@material-hu/components/design-system/Buttons/Button';
import HuTooltip from '@material-hu/components/design-system/Tooltip';

import { Document } from 'src/types/documents';
import { useLokaliseTranslation } from 'src/utils/i18n';

type SignButtonProps = {
  document: Document;
  handleClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
};

const SignButton = ({ document, handleClick }: SignButtonProps) => {
  const { t } = useLokaliseTranslation('documents');
  const canBeSigned = document?.canBeSigned;

  return (
    <HuTooltip
      title={t('CANT_SIGN_THIS_DOCUMENT_TEXT')}
      disableTooltip={canBeSigned}
    >
      <span>
        <Button
          variant="primary"
          onClick={handleClick}
          disabled={!canBeSigned}
        >
          {t('SIGN')}
        </Button>
      </span>
    </HuTooltip>
  );
};

export default SignButton;
