<commit_before>import React from 'react';

import { isUnlimited, isExpired, hasExpiry, isDateField, formatDate } from '../util';
import COLUMN_NAMES, { VALID, NAME, CODE } from '../data/columnNames';

export default ({ modules, serverID }) => (
  (!modules || !serverID) ? (
    <span></span>
  ) : (
    <div>
      <h2>Captiva Capture License ID: {serverID}</h2>
      <table>
        <tbody>
          <tr>
            {COLUMN_NAMES.map((column, i) => (
              <th key={i}>{column}</th>
            ))}
          </tr>
          {modules.map((row, i) => (
            <tr style={rowStyle(row)} key={i}>
              {COLUMN_NAMES.map((column, i) => (
                <td style={cellStyle(row, column)} key={i}>
                  {cellContents(row, column)}
                </td>
              ))}
            </tr>
          ))}
        </tbody>
      </table>
    </div>
  )
);

function cellContents(row, column) {
  return isDateField(column) ? (
    formatDate(row[column])
  ) : (isUnlimited(column) && row[column] === '0') ?
    'Unlimited' : row[column];
}

function cellStyle(row, column) {
  return {
    fontWeight: (column === VALID) ? 'bold' : 'inherit',
    textAlign: (column === CODE || column === NAME) ? 'left' : 'center'
  };
}

function rowStyle(row) {
  return isExpired(row) ? {
    color: 'red',
    backgroundColor: 'pink'
  } : hasExpiry(row) ? {
    color: 'darkgreen',
    backgroundColor: 'lightgreen'
  } : {};
}<commit_msg>Make colors more consistent and add NAME color grouping<commit_after>import React from 'react';

import { isUnlimited, isExpired, hasExpiry, isDateField, formatDate } from '../util';
import COLUMN_NAMES, { VALID, NAME, CODE } from '../data/columnNames';

export default ({ modules, serverID }) => (
  (!modules || !serverID) ? (
    <span></span>
  ) : (
    <div>
      <h2>Captiva Capture License ID: {serverID}</h2>
      <table>
        <tbody>
          <tr>
            {COLUMN_NAMES.map((column, i) => (
              <th key={i}>{column}</th>
            ))}
          </tr>
          {modules.map((row, i) => (
            <tr style={rowStyle(row)} key={i}>
              {COLUMN_NAMES.map((column, i) => (
                <td style={cellStyle(row, column)} key={i}>
                  {cellContents(row, column)}
                </td>
              ))}
            </tr>
          ))}
        </tbody>
      </table>
    </div>
  )
);

function cellContents(row, column) {
  return isDateField(column) ? (
    formatDate(row[column])
  ) : (isUnlimited(column) && row[column] === '0') ?
    'Unlimited' : row[column];
}

function cellStyle(row, column) {
  return {
    fontWeight: (column === VALID) ? 'bold' : 'inherit',
    textAlign: (column === CODE || column === NAME) ? 'left' : 'center',
    backgroundColor: (column === NAME) ? (
      (row[NAME].startsWith(' ')) ? '#BBDEFB' : '#64B5F6'
    ) : undefined,
    color: (column === NAME) ? '#000000' : undefined
  };
}

function rowStyle(row) {
  return isExpired(row) ? {
    color: '#B71C1C',
    backgroundColor: '#FFCDD2'
  } : hasExpiry(row) ? {
    color: '#1B5E20',
    backgroundColor: '#C8E6C9'
  } : {};
}
{'fraction_non_alphanumeric': 0.1851145038167939, 'fraction_numerical': 0.008587786259541985, 'mean_word_length': 2.2590673575129534, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4379474', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1061, 'n_words': 216}