Kercode/tutti_gruppi

View on GitHub
app/views/admin/dashboard/show.html.erb

Summary

Maintainability
Test Coverage
<div class="container text-center mt-3">
  <% if current_authentication.admin? %>
    <h4>Profil de <%= @authentication.fullname %> (<%= @authentication.userable_type %>)</h4>
    <% if @orders == [] %>
      <p>Cet utilisateur n'a pas encore passé commande</p>
    <% else %>
      <%= order_count @orders %>
      <hr>
      <% @orders.each do |order| %>
        <strong>Commande n°<%= order.id %> :</strong>
        <% @orderitems = OrderItem.where(order_id: order.id) %>
          <% @orderitems.each do |orderitem| %>
            <% if orderitem.quantity > 0 %>
              <p>
                <%= orderitem.quantity %>
                <%= orderitem.pluralize(t('orders.show.package')) %>
                 <%= orderitem.product.name %> 
                pour <%= render_price_to_euros(orderitem.unit_price_x_quantity) %> 
              </p>
            <% end %>
          <% end %>
        <p>Total : <%= render_price_to_euros(order.total) %></p> 
      <hr>
      <% end %>
      <%= paginate @orders %>
    <% end %>
  <% else %>
    <h2>Accès refusé</h2>
  <% end %>
  <%= link_to 'Back', admin_liste_des_membres_path, id: 'btns' %>
</div>