All files / src/list/SecondaryText ContactName.js

100% Statements 7/7
52.94% Branches 9/17
100% Functions 1/1
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93                                                      1x               1x 1x 1x 1x                                                                                         2x 2x                
import React, { Component } from 'react';
import { ContactName_defaultProps } from './props/defaultProps';
import { ContactName_propTypes } from './props/propTypes';
import { Container, Box } from '@zohodesk/components/lib/Layout';
import Link from '../../Link/Link';
import SentimentStatus from '../SentimentStatus/SentimentStatus';
import { Icon } from '@zohodesk/icons';
 
import style from './SecondaryText.module.css';
export default class ContactName extends Component {
  render() {
    let {
      dataTitle,
      dataId,
      isPaidUser,
      urlName,
      urlData,
      onClick,
      sentimentType,
      isLink,
      className,
      text,
      href,
      notAccessible = false,
      fontWeight,
      i18nKeys,
      customProps
    } = this.props;
    let {
      sentimentTitles = {
        positive: 'Positive',
        negative: 'Negative',
        neutral: 'Neutral'
      },
      paidTitle = 'Paid User'
    } = i18nKeys;
    let sentimentDataTitle = sentimentTitles[sentimentType];
    let { LinkProps = {}, TextProps = {} } = customProps;
    return (
      <Container alignBox='row' align='baseline' isCover={false} dataId={dataId}>
        {isPaidUser && (
          <Box className={style.paidUserIcon} title={paidTitle} aria-label='Paid user'>
            <Icon name='ZD-paiduser' iconClass={style.icon} />
          </Box>
        )}
        <Box flexible>
          {isLink ? (
            <Link
              urlName={urlName}
              href={href}
              urlData={urlData}
              onClick={onClick}
              title={dataTitle}
              dataId={`${dataId}_link`}
              className={style.link}
              {...LinkProps}
              ariaLabel={`Contact Name ${text}`}
            >
              <div className={`${style.textStyle} ${style[`font_${fontWeight}`]} ${className ? className : ''}`}>
                {text}
              </div>
            </Link>
          ) : (
            <div
              className={`${style.secondaryText} ${style[`font_${fontWeight}`]} ${className ? className : ''} ${
                notAccessible ? style.disable : ''
              }`}
              data-title={dataTitle}
              {...TextProps}
            >
              {text}
            </div>
          )}
        </Box>
        {sentimentType && (
          <Box>
            <SentimentStatus type={sentimentType} dataTitle={sentimentDataTitle} />
          </Box>
        )}
      </Container>
    );
  }
}
ContactName.propTypes = ContactName_propTypes;
ContactName.defaultProps = ContactName_defaultProps;
 
// if (__DOCS__) {
//   ContactName.docs = {
//     folderName: 'List',
//     componentGroup: 'ContactName'
//   };
// }