<commit_before>import * as BooksAPI from'./BooksAPI'
import React, { Component } from 'react';
import {Link } from 'react-router-dom';
import Book from './book'
//import serializeForm from 'form-serialize'
class Search extends Component{
  state = {
    query:''
  }
  search=(e)=>{
    e.preventDefault();
    console.log(e.target.value)
    //const searchTerm=serializeForm(e.target,{hash:true});
    let searchTerm=e.target.value
    BooksAPI.search(searchTerm,10).then((data)=>{
      console.log(data)
      this.setState({query:data})
    })
    console.log(searchTerm);
    console.log('in search');
  }
  render(){
    const onBookChange=this.props.onBookChange;
    let data=this.state.query
    let searchResult=""
    if ((data) &&!(data.error)){ // checking if result from server does not contain error
      console.log(JSON.stringify(data))
      searchResult=data.map(b=><Book key={b.id} info={b} onBookChange={onBookChange}/>)
    }

    return(
      <div className="search-books">
        <div className="search-books-bar">
          <Link className="close-search" to="/">Close</Link>
          <div className="search-books-input-wrapper">
            <input type="text" onInput={this.search} name="search" placeholder="Search by title or author"/>
          </div>
        </div>
        <div className="search-books-results">
          <ol className="books-grid">
            {searchResult}
          </ol>
        </div>
      </div>
    )}
  }
  export default Search;<commit_msg>style: Name meaningfully the functions<commit_after>import * as BooksAPI from'./BooksAPI'
import React, { Component } from 'react';
import {Link } from 'react-router-dom';
import Book from './book'
//import serializeForm from 'form-serialize'
class Search extends Component{
  state = {
    books:''
  }
  searchBooks=(e)=>{
    e.preventDefault();
    console.log(e.target.value)
    //const searchTerm=serializeForm(e.target,{hash:true});
    let searchTerm=e.target.value
    BooksAPI.search(searchTerm,10).then((data)=>{
      console.log(data)
      this.setState({books:data})
    })
    console.log(searchTerm);
    console.log('in search');
  }

  render(){
    const onBookChange=this.props.onBookChange;
    let searchedBooksList=this.state.books

    let searchResult=""
    if ((searchedBooksList) &&!(searchedBooksList.error)){ // checking if result from server does not contain error
      console.log(JSON.stringify(searchedBooksList))
      searchResult=searchedBooksList.map(b=><Book key={b.id} info={b} onBookChange={onBookChange}/>)
    }

    return(
      <div className="search-books">
        <div className="search-books-bar">
          <Link className="close-search" to="/">Close</Link>
          <div className="search-books-input-wrapper">
            <input type="text" onInput={this.searchBooks} name="search" placeholder="Search by title or author"/>
          </div>
        </div>
        <div className="search-books-results">
          <ol className="books-grid">
            {searchResult}
          </ol>
        </div>
      </div>
    )}
  }
  export default Search;
{'fraction_non_alphanumeric': 0.1522858982614295, 'fraction_numerical': 0.00128783000643915, 'mean_word_length': 3.009032258064516, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 37, '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': '7608049', 'n_tokens_mistral': 946, 'n_tokens_neox': 925, 'n_words': 195}