{"size": 803, "ext": "js", "max_stars_repo_path": "modules/display.js", "max_stars_repo_name": "david-lafontant/AwesomeBooks_v2", "max_stars_repo_stars_event_min_datetime": "2022-01-18T02:18:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-08T14:33:52.000Z", "max_issues_repo_path": "modules/display.js", "max_issues_repo_name": "david-lafontant/AwesomeBooks_v2", "max_issues_repo_issues_event_min_datetime": "2022-01-18T03:29:28.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-25T14:40:25.000Z", "max_forks_repo_path": "modules/display.js", "max_forks_repo_name": "david-lafontant/AwesomeBooks_v2", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 4, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 24.3333333333, "max_line_length": 78, "alphanum_fraction": 0.6438356164}
import Store from './store.js';

export default class displayBook {
  static displayBooks() {
    const books = Store.getBooks();

    books.forEach((book) => displayBook.addBookToList(book));
  }

  static addBookToList(book) {
    const elementList = document.getElementById('listBooks');
    const listItem = document.createElement('li');

    listItem.innerHTML = `
      <span>"${book.title}" by ${book.author}</span>
      <button type='button' id='${book.id}' class='remove-btn'>Remove</button>
      `;

    elementList.appendChild(listItem);
  }

  static deleteBook(el) {
    if (el.classList.contains('remove-btn')) {
      el.parentElement.remove();
    }
  }

  static clearFields() {
    document.querySelector('#title').value = '';
    document.querySelector('#author').value = '';
  }
}
