all files / src/components/ ColumnTypeLabel.jsx

92.31% Statements 24/26
88.89% Branches 24/27
100% Functions 1/1
91.67% Lines 22/24
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                                
import React from 'react';
import PropTypes from 'prop-types';
 
const propTypes = {
  type: PropTypes.string,
};
 
export default function ColumnTypeLabel({ type }) {
  let stringIcon = '';
  if (Itypeof type !== 'string') {
    stringIcon = '?';
  } else if (type === '' || type === 'expression') {
    stringIcon = 'ƒ';
  } else Iif (type === 'aggregate') {
    stringIcon = 'AGG';
  } else if (type.match(/.*char.*/i) || type.match(/string.*/i) || type.match(/.*text.*/i)) {
    stringIcon = 'ABC';
  } else if (type.match(/.*int.*/i) || type === 'LONG' || type === 'DOUBLE' || type === 'FLOAT') {
    stringIcon = '#';
  } else if (type.match(/.*bool.*/i)) {
    stringIcon = 'T/F';
  } else if (type.match(/.*time.*/i)) {
    stringIcon = 'time';
  } else Eif (type.match(/unknown/i)) {
    stringIcon = '?';
  }
 
  const typeIcon = stringIcon === 'time' ?
    <i className="fa fa-clock-o type-label" /> :
    <div className="type-label">{stringIcon}</div>;
 
  return (
    <span>
      {typeIcon}
    </span>);
}
ColumnTypeLabel.propTypes = propTypes;