<commit_before>import React from 'react';
import data from '../dummyData'
import Notes from './notes';

class Sidebar extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      notes: data
    };
  }
  render() {
    return (
      <section ref="sidebar" className="sidebar">
        <header className="sidebar__header"><h1>Notes</h1></header><commit_msg>creating callbacks for dealing with search and new notes<commit_after>import React from 'react';
import Immutable from 'immutable';
import data from '../dummyData';
import Notes from './notes';
import Header from './header';

class Sidebar extends React.Component {
  constructor(props) {
    super(props);

    // TODO: Look in to es7 features
    this.handleSearch = this.handleSearch.bind(this);
    this.handleCreate = this.handleCreate.bind(this);

    this.state = {
      data: data,
      notes: data
    };
  }
  handleSearch(searchTerm) {
    let results = Immutable.List(
      this.state.data.filter(
        note => note.get('title').indexOf(searchTerm) !== -1
    ));

    this.setState(
      {notes: results}
    );
  }
  handleCreate(title) {
    let date = new Date();
    title = title || `Untitled-${date.getMonth() + 1}-${date.getDate()}-${date.getFullYear()}`;

    let newNote = Immutable.Map({title});
    // TODO: Add data store with actions
    let data = this.state.data.unshift(newNote);
    this.setState(
      {data, notes: data}
    );
  }
  render() {
    return (
      <section ref="sidebar" className="sidebar">
        <Header onSearch={this.handleSearch} onCreate={this.handleCreate} />
{'fraction_non_alphanumeric': 0.14516129032258066, 'fraction_numerical': 0.003101736972704715, 'mean_word_length': 3.104325699745547, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 11, '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': '1174715', 'n_tokens_mistral': 486, 'n_tokens_neox': 482, 'n_words': 120}