| Total Complexity | 1 |
| Complexity/F | 0 |
| Lines of Code | 40 |
| Function Count | 0 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | import React from 'react'; |
||
| 2 | import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; |
||
| 3 | import { faInfoCircle as infoIcon } from '@fortawesome/free-solid-svg-icons'; |
||
| 4 | import { UncontrolledTooltip } from 'reactstrap'; |
||
| 5 | import { shortUrlType } from '../reducers/shortUrlsList'; |
||
| 6 | |||
| 7 | 4 | const propTypes = { |
|
| 8 | shortUrl: shortUrlType, |
||
| 9 | }; |
||
| 10 | |||
| 11 | 4 | const ShortUrlVisitsCount = ({ shortUrl }) => { |
|
| 12 | 4 | const { visitsCount, meta } = shortUrl; |
|
| 13 | 4 | const maxVisits = meta && meta.maxVisits; |
|
| 14 | |||
| 15 | 4 | if (!maxVisits) { |
|
| 16 | 3 | return <span>{visitsCount}</span>; |
|
| 17 | } |
||
| 18 | |||
| 19 | 1 | return ( |
|
| 20 | <React.Fragment> |
||
| 21 | <span> |
||
| 22 | {visitsCount} |
||
| 23 | <small id="maxVisitsControl" className="short-urls-row__max-visits-control"> |
||
| 24 | {' '}/ {maxVisits}{' '} |
||
| 25 | <sup> |
||
| 26 | <FontAwesomeIcon icon={infoIcon} /> |
||
| 27 | </sup> |
||
| 28 | </small> |
||
| 29 | </span> |
||
| 30 | <UncontrolledTooltip target="maxVisitsControl" placement="bottom"> |
||
| 31 | This short URL will not accept more than <b>{maxVisits}</b> visits. |
||
| 32 | </UncontrolledTooltip> |
||
| 33 | </React.Fragment> |
||
| 34 | ); |
||
| 35 | }; |
||
| 36 | |||
| 37 | 4 | ShortUrlVisitsCount.propTypes = propTypes; |
|
| 38 | |||
| 39 | export default ShortUrlVisitsCount; |
||
| 40 |