<div class="row">
  <div class="col-xs-12">

    <div class="page-header">
      <h1>Recipes</h1>
    </div>

    <% if @recipes.empty? %>
      <p>No Recipes</p>
    <% else %>

      <div class="table-responsive">
        <table class="recipe-table table table-striped table-hover">
          <thead>
            <tr>
              <th>Name</th>
              <th>Rating</th>
              <th>Yields</th>
              <th>Time</th>
              <th>Created</th>
              <% if current_user? %>
                <th></th>
              <% end %>
            </tr>
          </thead>

          <tbody>
            <% decorate(@recipes, RecipeDecorator).each do |recipe| %>
              <tr>
                <td><%= link_to recipe.short_name, recipe %></td>
                <td>
                  <% if recipe.average_rating > 0 %>
                    <input type="hidden" class="rating" value="<%= recipe.average_rating %>" />
                  <% else %>
                    --
                  <% end %>
                </td>
                <td><%= recipe.yields %></td>
                <td><%= recipe_time(recipe) %></td>
                <td><%= timestamp(recipe.created_at) %></td>
                <% if current_user? %>
                  <td>
                    <%= link_to new_recipe_log_path(recipe), class: 'btn btn-sm btn-primary' do %>
                      <span class="glyphicon glyphicon-copy"></span>
                    <% end %>
                    <%= link_to edit_recipe_path(recipe), class: 'btn btn-sm btn-primary' do %>
                      <span class="glyphicon glyphicon-pencil"></span>
                    <% end %>
                    <%= link_to recipe, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-sm btn-danger' do %>
                      <span class="glyphicon glyphicon-remove"></span>
                    <% end %>
                  </td>
                <% end %>
              </tr>
            <% end %>
          </tbody>
        </table>
      </div>

    <% end %>

    <br>

    <%= link_to 'New Recipe', new_recipe_path, class: 'btn btn-default' %>

  </div>
</div>