<h1 class="my-4">Book Details</h1>
<div class="row">
  <div class="col-sm-6">
    <table class="table table-bordered">
      <tr>
        <th scope="col">Title</th>
        <td><%= @book.title %></td>
      </tr>
      <tr>
        <th scope="col">Genre</th>
        <td><%= @book.genre %></td>
      </tr>
      <tr>
        <th scope="col">Sub Genre</th>
        <td><%= @book.sub_genre %></td>
      </tr>
      <tr>
        <th scope="col">Author</th>
        <td><%= @book.author %></td>
      </tr>
      <tr>
        <th scope="col">Pages</th>
        <td><%= @book.pages %></td>
      </tr>
      <tr>
        <th scope="col">Total Copies</th>
        <td><%= @book.copies %></td>
      </tr>
      <tr>
        <th scope="col">Available Copies</th>
        <td><%= @book.available_copies %></td>
      </tr>
    </table>
  </div>
</div>
<h3 class="my-4">Check out Status</h3>
<div class="row">
  <div class="col-sm-12">
    <table class="table table-bordered">
      <thead>
        <th>#</th>
        <th>Book copy code</th>
        <th>Status</th>
        <th>Email</th>
        <th>Borrow date</th>
        <th>Expected Return date</th>
        <th>Actual Returned Date</th>
      </thead>
      <tbody>
        <% @book.users_books.each_with_index do |user_book, index| %>
        <tr>
          <td><%= index + 1 %></td>
          <td><%= user_book.identifier %></td>
          <td><%= user_book.status %></td>
          <td><%= user_book.user.email %></td>
          <td><%= decorate_date(user_book.created_at) %></td>
          <td><%= decorate_date(user_book.due_date) %></td>
          <td><%= decorate_date(user_book.returned_at) %></td>
        </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>