<commit_before>import React, { Component } from 'react';
import { connect } from 'react-redux';

import '../../styles/share.scss';

const mapStateToProps = state => ({
  itinerary: state.itinerary,
});

class Share extends Component {

  createMessageBody(itinerary) {
    const newline = '%0A%0A';
    const lineBreak = '%0A';
    const indent = '%20%20';
    const dash = '%2D%20';

    return 'My Trip Details'.concat(newline) + Object.keys(itinerary)
      .reduce((body, city) => (
        body.concat(`${city}${newline}`,
          itinerary[city].reduce((acc, POI) => (
            acc.concat(`${dash}${POI.name}${newline}${indent}${POI.formatted_phone_number}${lineBreak}${indent}${POI.international_phone_number}${lineBreak}${indent}${POI.formatted_address}${newline}`)
          ), ''),
        )
    ), '');
  }

  render() {
    const itinerary = this.props.itinerary.itinerary;
    const message = this.createMessageBody(itinerary);

    return (
      <div>
        <a
          target="_blank"
          href={`mailto:?subject=My%20Trip%20Itinerary&body=${message}`}
        >
          Email Me This Info
        </a>
      </div>
    );
  }
}

export default connect(mapStateToProps)(Share);<commit_msg>Fix '&' bug in email populating function<commit_after>import React, { Component } from 'react';
import { connect } from 'react-redux';

import '../../styles/share.scss';

const mapStateToProps = state => ({
  itinerary: state.itinerary,
});

const lineBreak = '%0A';
const indent = '%20%20';
const newline = '%0A%0A';
const dash = '%2D%20';

class Share extends Component {

  populateDetails(string) {
    if (string !== undefined && string.length > 0) {
      console.log('encodeURIComponent(string) is', encodeURIComponent(string));
      return `${encodeURIComponent(string)}${lineBreak}${indent}`;
    }
  }

  createMessageBody(itinerary) {
    return 'Here are the highlights for my trip:'.concat(newline) + Object.keys(itinerary)
      .reduce((body, city) => (
        body.concat(`${city}${newline}`,
          itinerary[city].reduce((acc, POI) => (
            acc.concat(`${dash}${encodeURIComponent(POI.name)}${newline}${indent}${this.populateDetails(POI.formatted_phone_number)}${this.populateDetails(POI.international_phone_number)}${this.populateDetails(POI.formatted_address)}${newline}`)
          ), ''),
        )
    ), '');
  }

  render() {
    const itinerary = this.props.itinerary.itinerary;
    const message = this.createMessageBody(itinerary);

    return (
      <a
        role="button"
        className="btn btn-success"
        rel="noopener noreferrer"
        target="_blank"
        href={`mailto:?subject=My%20Trip%20Details&body=${message}`}
      >
        Email Me This Info
      </a>
    );
  }
}

export default connect(mapStateToProps)(Share);
{'fraction_non_alphanumeric': 0.16809116809116809, 'fraction_numerical': 0.010327635327635327, 'mean_word_length': 3.3348765432098766, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 16, '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': '354385', 'n_tokens_mistral': 933, 'n_tokens_neox': 921, 'n_words': 152}