Completed
Push — master ( e96c11...f507a3 )
by Alejandro
19s queued 11s
created

src/short-urls/helpers/ShortUrlVisitsCount.js   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 40
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 35
mnd 1
bc 1
fnc 0
dl 0
loc 40
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
ccs 8
cts 8
cp 1
rs 10
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