<commit_before>// @flow
import React, { Component } from 'react';
import Select from '../components/SweetSelect/SweetSelect';
import Input from '../components/SweetInput/SweetInput';
import Button from '../components/Button/Button';
import SelectCountry from '../components/SelectCountry/SelectCountry';
import { FormattedMessage } from 'react-intl';
import './EmailToolView.scss';

type Props = {
  emailBody: string,
  emailHeader: string,
  emailFooter: string,
  emailSubject: string,
  country: string,
  email: string,
  name: string,
  pensionFunds: Array<string>,
  isSubmitting: boolean,
  to: string,
  fundId: string,
  fund: string,
  fundContact: string,
  fundEmail: string,
  page: string,
};

type State = {
  name: string,
  errors: { [field: string]: string },
};

export default class EmailToolView extends Component {
  props: Props;
  state: State;

  constructor(props: Props) {
    super(props);
    this.state = {
      name: '',
      errors: {},
    };
  }

  onSubmit = e => {
    e.preventDefault();
  };

  parseHeader() {
    return { __html: this.parse(this.props.emailHeader) };
  }

  parseFooter() {
    return { __html: this.parse(this.props.emailFooter) };
  }

  prepBody() {
    return `${this.parseHeader().__html}\n\n${this.props
      .emailBody}\n\n${this.parseFooter().__html}`;
  }

  parse(template) {
    template = template.replace(/(?:\r\n|\r|\n)/g, '<br />');
    template = _.template(template);
    return template(this.props);<commit_msg>[wip] Email tool populate state from props<commit_after>// @flow
import React, { Component } from 'react';
import Select from '../components/SweetSelect/SweetSelect';
import Input from '../components/SweetInput/SweetInput';
import Button from '../components/Button/Button';
import SelectCountry from '../components/SelectCountry/SelectCountry';
import { FormattedMessage } from 'react-intl';
import './EmailToolView.scss';

type Props = {
  emailBody: string,
  emailHeader: string,
  emailFooter: string,
  emailSubject: string,
  country: string,
  email: string,
  name: string,
  pensionFunds: Array<string>,
  isSubmitting: boolean,
  to: string,
  fundId: string,
  fund: string,
  fundContact: string,
  fundEmail: string,
  page: string,
};

type State = Props & {
  name: string,
  errors: { [field: string]: string },
};

export default class EmailToolView extends Component {
  props: Props;
  state: State;

  constructor(props: Props) {
    super(props);
    this.state = {
      ...this.props,
      name: '',
      errors: {},
    };
  }

  onSubmit = e => {
    e.preventDefault();
  };

  parseHeader() {
    return { __html: this.parse(this.props.emailHeader) };
  }

  parseFooter() {
    return { __html: this.parse(this.props.emailFooter) };
  }

  prepBody() {
    return `${this.parseHeader().__html}\n\n${this.props
      .emailBody}\n\n${this.parseFooter().__html}`;
  }

  parse(template) {
    template = template.replace(/(?:\r\n|\r|\n)/g, '<br />');
    template = _.template(template);
    return template(this.props);
{'fraction_non_alphanumeric': 0.15602369980250164, 'fraction_numerical': 0.0, 'mean_word_length': 3.5223214285714284, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '2638489', 'n_tokens_mistral': 987, 'n_tokens_neox': 970, 'n_words': 223}