<commit_before>import React from 'react';
import { connect } from 'react-redux';
import { selectMarker } from 'routes/Dashboard/modules/Dashboard';
import classes from './PopUpCard.scss';
import ShipmentCard from './ShipmentCard';
import RetailerCard from './RetailerCard';
import StormCard from './StormCard';
import DCCard from './DCCard';

const showSelectedInfo = ({ type, data }) => { // eslint-disable-line
  if (type === 'distributionCenter') {
    return (
      <DCCard
        contact={data.contact.name}
        address={data.address}
        shipments={data.shipments}
      />
    );
  }
  else if (type === 'shipment') {
    return (
      <ShipmentCard shipment={data} />
    );
  }
  else if (type === 'retailer') {
    return (
      <RetailerCard
        managerId={data.managerId}
        address={data.address}
      />
    );
  }
  else if (type === 'storm') {
    return (
      <StormCard storm={data} />
    );
  }
  else if (type === 'hidden') {
    return '';
  }

  console.error('Invalid info type passed to showSelectedInfo in Map.jsx');
  return '';
};

const formatTitle = type => {
  const titles = {
    distributionCenter: 'Distribution Center',
    retailer: 'Retail Location',
    shipment: 'Shipment',
    storm: 'Weather Alert',
  };

  return titles[type] || '';
};

const PopUpCard = ({ infoBox }) => (
  <div className={`${classes.wrapper} ${classes[infoBox.type]}`}>
    <div className={classes.title}>
      <h4>{formatTitle(infoBox.type)} {infoBox.data.id}</h4>
      <i className={`fa fa-times-circle-o ${classes.closeIcon}`} />
    </div>
    {showSelectedInfo(infoBox)}
  </div>
);

PopUpCard.propTypes = {
  selectMarker: React.PropTypes.func.isRequired,
  infoBox: React.PropTypes.shape({<commit_msg>#95 close button<commit_after>import React from 'react';
import { connect } from 'react-redux';
import { selectMarker } from 'routes/Dashboard/modules/Dashboard';
import classes from './PopUpCard.scss';
import ShipmentCard from './ShipmentCard';
import RetailerCard from './RetailerCard';
import StormCard from './StormCard';
import DCCard from './DCCard';


const showSelectedInfo = ({ type, data }) => { // eslint-disable-line
  if (type === 'distributionCenter') {
    return (
      <DCCard
        contact={data.contact.name}
        address={data.address}
        shipments={data.shipments}
      />
    );
  }
  else if (type === 'shipment') {
    return (
      <ShipmentCard shipment={data} />
    );
  }
  else if (type === 'retailer') {
    return (
      <RetailerCard
        managerId={data.managerId}
        address={data.address}
      />
    );
  }
  else if (type === 'storm') {
    return (
      <StormCard storm={data} />
    );
  }
  else if (type === 'hidden') {
    return '';
  }

  console.error('Invalid info type passed to showSelectedInfo in Map.jsx');
  return '';
};

const formatTitle = type => {
  const titles = {
    distributionCenter: 'Distribution Center',
    retailer: 'Retail Location',
    shipment: 'Shipment',
    storm: 'Weather Alert',
  };

  return titles[type] || '';
};


const PopUpCard = ({ infoBox, selectMarker }) => (
  <div className={`${classes.wrapper} ${classes[infoBox.type]}`}>
    <div className={classes.title}>
      <h4>{formatTitle(infoBox.type)} {infoBox.data.id}</h4>
      <i className={`fa fa-times-circle-o ${classes.closeIcon}`} onClick={() => selectMarker('hidden', {})} />
    </div>
    {showSelectedInfo(infoBox)}
  </div>
);

PopUpCard.propTypes = {
  selectMarker: React.PropTypes.func.isRequired,
  infoBox: React.PropTypes.shape({
{'fraction_non_alphanumeric': 0.1662921348314607, 'fraction_numerical': 0.0016853932584269663, 'mean_word_length': 3.140697674418605, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 32, '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': '4937949', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1147, 'n_words': 246}