<commit_before>import React from 'react';
import { Link } from 'react-router-dom';

const BorrowedBooks = (props) => {
  const { books } = props;
  if (!books.length) {
    return (
        <div className="row center">
            <p className="grey-text">You have no borrowed books </p>
        </div>
    );
  }

  return (
        <div className="row">
            <table className="striped responsive-table">
                <thead>
                    <tr>
                        <th>Book</th>
                        <th>Date Borrowed</th>
                        <th>Status</th>
                        <th>Date Returned</th>
                    </tr>
                </thead>
                <tbody>
                    { books.map((book, index) =>
                        <tr key={ index }>
                            <td><Link to= {`/books/${book.bookId}`}> { book.borrowedBooks.title } </Link></td>
                            <td> { book.createdAt.split('T')[0] } </td>
                            <td> { book.status } </td>
                            <td> { book.status === 'Returned' ? book.updatedAt.split('T')[0] : '' } </td>
                            { book.status !== 'Returned' &&
                            <td><button>Return</button></td>
                            }
                        </tr>)}
                </tbody>
            </table>
        </div>
  );
};

export default BorrowedBooks;<commit_msg>Add method to return book in component<commit_after>import React from 'react';
import { Link } from 'react-router-dom';

const BorrowedBooks = (props) => {
  const {
    books, returnBook, user, isSendingRequest, returnRequests,
  } = props;
  console.log(props);

  if (!books.length) {
    return (
        <div className="row center">
            <p className="grey-text">You have no borrowed books </p>
        </div>
    );
  }

  return (
        <div className="row">
            <table className="striped responsive-table">
                <thead>
                    <tr>
                        <th>Book</th>
                        <th>Date Borrowed</th>
                        <th>Status</th>
                        <th>Date Returned</th>
                    </tr>
                </thead>
                <tbody>
                    { books.map((book, index) =>
                        <tr key={ index }>
                            <td><Link to= {`/books/${book.bookId}`}> { book.borrowedBooks.title } </Link></td>
                            <td> { book.createdAt.split('T')[0] } </td>
                            <td> { book.status } </td>
                            <td> { book.status === 'Returned' ? book.updatedAt.split('T')[0] : '' } </td>
                            { book.status !== 'Returned' &&
                            !returnRequests.find(request =>
                                request.bookId === book.bookId) &&
                            <td><button onClick = { returnBook.bind(null, user.id, book.bookId) }
                            className = "btn btn-small btn-wave waves-effect red"
                            disabled = { isSendingRequest } >Return</button></td>
                            }
                        </tr>)}
                </tbody>
            </table>
        </div>
  );
};

export default BorrowedBooks;
{'fraction_non_alphanumeric': 0.14397826743133113, 'fraction_numerical': 0.0012073649260488982, 'mean_word_length': 1.109484404837683, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 84, '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': '3291331', 'n_tokens_mistral': 919, 'n_tokens_neox': 877, 'n_words': 178}