<commit_before>import { connect } from 'react-redux';
import { Link } from 'react-router';
import React from 'react';
import _ from 'lodash';

import Header from '../../app/Header';
import Icon from '../../widgets/Icon';
import { deleteDraft } from './EditorActions';

let DraftRow = (props) => {
  const { id, data } = props;
  let { title = '', body = '' } = data;
  title = title.trim();
  body = body.replace(/\r?\n|\r|[\u200B-\u200D\uFEFF]/g, ' ').substring(0, 50);
  let draftTitle = title.length ? title : body;
  draftTitle = draftTitle.trim();
  if (draftTitle.length === 0) {
    draftTitle = 'Untitled Draft';
  }
  return (<div>
    <Link to={{ pathname: '/write', query: { draft: id } }}>{draftTitle}</Link>
    <a onClick={() => { props.deleteDraft(id); }}><Icon name="cancel" /></a>
  </div>);
};

DraftRow = connect(() => ({}), { deleteDraft })(DraftRow);

const DraftList = ({ editor: { draftPosts } }) =>
  (
    <div className="main-panel">
      <Header />
      <div className="container my-3">
        Your Drafts
          {_.map(draftPosts, (draft, key) => <DraftRow key={key} data={draft.postData} id={key} />)}
      </div>
    </div>
  );

export default connect(state => ({ editor: state.editor }))(DraftList);<commit_msg>Improve style<commit_after>import { connect } from 'react-redux';
import { Link } from 'react-router';
import React from 'react';
import _ from 'lodash';

import Header from '../../app/Header';
import Icon from '../../widgets/Icon';
import { deleteDraft } from './EditorActions';

let DraftRow = (props) => {
  const { id, data } = props;
  let { title = '', body = '' } = data;
  title = title.trim();
  body = body.replace(/\r?\n|\r|[\u200B-\u200D\uFEFF]/g, ' ').substring(0, 50);
  let draftTitle = title.length ? title : body;
  draftTitle = draftTitle.trim();
  if (draftTitle.length === 0) {
    draftTitle = 'Untitled Draft';
  }
  return (<h3>
    <Link to={{ pathname: '/write', query: { draft: id } }}>{draftTitle}</Link>
    <a onClick={() => { props.deleteDraft(id); }}><Icon name="cancel" /></a>
  </h3>);
};

DraftRow = connect(() => ({}), { deleteDraft })(DraftRow);

const DraftList = ({ editor: { draftPosts } }) =>
  (
    <div className="main-panel">
      <Header />
      <div className="my-3">
        <h1 className="text-xs-center">Drafts</h1>
        <div className="container">
          { _.size(draftPosts) === 0 &&
            <h3 className="text-xs-center">
              You don't have any draft saved.
            </h3>
          }
          { _.map(draftPosts, (draft, key) =>
            <DraftRow key={key} data={draft.postData} id={key} />)
          }
        </div>
      </div>
    </div>
  );

export default connect(state => ({ editor: state.editor }))(DraftList);
{'fraction_non_alphanumeric': 0.20769789397240376, 'fraction_numerical': 0.010530137981118372, 'mean_word_length': 2.9022662889518416, 'pattern_counts': {'":': 0, '<': 35, '<?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': '3186597', 'n_tokens_mistral': 954, 'n_tokens_neox': 922, 'n_words': 223}