import copyIcon from '@fortawesome/fontawesome-free-regular/faCopy'; import FontAwesomeIcon from '@fortawesome/react-fontawesome'; import { isNil } from 'ramda'; import React from 'react'; import { CopyToClipboard } from 'react-copy-to-clipboard'; import { Card, CardBody, Tooltip } from 'reactstrap'; import PropTypes from 'prop-types'; import { createShortUrlResultType } from '../reducers/shortUrlCreationResult'; import { stateFlagTimeout } from '../../utils/utils'; import './CreateShortUrlResult.scss'; export default class CreateShortUrlResult extends React.Component { static propTypes = { resetCreateShortUrl: PropTypes.func, error: PropTypes.bool, result: createShortUrlResultType, }; state = { showCopyTooltip: false }; componentDidMount() { this.props.resetCreateShortUrl(); } render() { const { error, result } = this.props; if (error) { return ( An error occurred while creating the URL :( ); } if (isNil(result)) { return null; } const { shortUrl } = result; const onCopy = () => stateFlagTimeout(this.setState.bind(this), 'showCopyTooltip'); return ( Great! The short URL is {shortUrl} Copied! ); } }