consul/consul

View on GitHub
app/components/admin/poll/officers/officers_component.html.erb

Summary

Maintainability
Test Coverage
<%= tag.table(**options) do %>
  <thead>
    <tr>
      <th><%= t("admin.poll_officers.officer.name") %></th>
      <th><%= t("admin.poll_officers.officer.email") %></th>
      <th><%= t("admin.actions.actions") %></th>
    </tr>
  </thead>
  <tbody>
    <% officers.each do |officer| %>
      <tr>
        <td>
          <%= officer.name %>
        </td>
        <td>
          <%= officer.email %>
        </td>
        <td>
          <% if officer.persisted? %>
            <%= render Admin::TableActionsComponent.new(
              officer,
              actions: [:destroy],
              destroy_text: t("admin.poll_officers.officer.delete"),
              destroy_options: { class: "destroy-officer-link" }
            ) %>
          <% else %>
            <%= render Admin::TableActionsComponent.new(officer, actions: []) do |actions| %>
              <%= actions.action(:create_officer,
                                 text: t("admin.poll_officers.officer.add"),
                                 path: add_user_path(officer),
                                 method: :post) %>
            <% end %>
          <% end %>
        </td>
      </tr>
    <% end %>
  </tbody>
<% end %>