Kercode/tutti_gruppi

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

Summary

Maintainability
Test Coverage
<% if current_authentication.admin? %>
  <h4>Liste des membres</h4>
    <table class="mx-auto">
      <tr>
        <th>Prénom</th>
        <th>Nom</th>
        <th>Email</th>
        <th>Role</th>
        <th>Groupement</th>
      </tr>

      <% @authentications.each do |auth| %>

        <tr>
          <td class="pt-4 pr-3"><%= auth.firstname %></td>
          <td class="pt-4 pr-3"><%= auth.lastname %></td>
          <td class="pt-4 pr-3"><%= auth.email %></td>
          <td class="pt-4 pr-3"><%= auth.userable_type %></td>
          <% group = GroupmentAuthentication.find_by_authentication_id(auth.id) %>          
          <td class="pt-4 pr-3"><%= group ? group.groupment.name : '' %></td>
          <td class="pt-4 pr-3"><%= mail_to "#{auth.email}", image_tag('contact.png', class:'icons', title: "Contacter #{auth.fullname}") %></td>
          <td class="pt-4 pr-3"><%= link_to image_tag('basket.png', class:'icons', title: "Commande(s) de #{auth.fullname}"), admin_path(auth) %></td>
          <td class="pt-4 pr-3"><%= link_to image_tag('edit.png', class:'icons', title: "Editer le profil de #{auth.fullname}"), edit_authentication_path(auth) %></td>
          <td class="pt-4 pr-3"><%= link_to image_tag('delete.png', class:'icons', title: "Supprimer le profil de #{auth.fullname}"), authentication_path(auth), method: :delete, data: {confirm: 'Etes vous sûr ?'} %></td>
        </tr>
        
      <% end %>
      <hr>
    </table>

    <div class="pagination-wrapper">
      <%= paginate @authentications, class: 'pt-3' %>
    </div>
    <hr>
    
<% else %>
    <h2>Accès refusé</h2>
<% end %>

<%= link_to raw('<i class="fas fa-chevron-left"></i> Retour'), admin_dashboard_path, id: 'btns' %>