<%= gettext("Ammo Types") %>

<%= if @ammo_types |> Enum.empty?() do %>

<%= gettext("No Ammo Types") %> <%= display_emoji("😔") %>

<%= live_patch(dgettext("actions", "Add your first type!"), to: Routes.ammo_type_index_path(Endpoint, :new), class: "btn btn-primary" ) %> <% else %> <%= live_patch(dgettext("actions", "New Ammo type"), to: Routes.ammo_type_index_path(Endpoint, :new), class: "btn btn-primary" ) %>
<%= for {field_name, _field, _type} <- @columns_to_display do %> <% end %> <%= for ammo_type <- @ammo_types do %> <%= for {_label, field, type} <- @columns_to_display do %> <% end %> <% end %>
<%= field_name %> <%= gettext("Total # of rounds") %>
<%= case type do %> <% :boolean -> %> <%= ammo_type |> Map.get(field) |> humanize() %> <% _other -> %> <%= ammo_type |> Map.get(field) %> <% end %> <%= ammo_type |> Ammo.get_round_count_for_ammo_type(@current_user) %>
<%= live_redirect to: Routes.ammo_type_show_path(Endpoint, :show, ammo_type), class: "text-primary-600 link", data: [qa: "view-#{ammo_type.id}"] do %> <% end %> <%= live_patch to: Routes.ammo_type_index_path(Endpoint, :edit, ammo_type), class: "text-primary-600 link", data: [qa: "edit-#{ammo_type.id}"] do %> <% end %> <%= link to: "#", class: "text-primary-600 link", phx_click: "delete", phx_value_id: ammo_type.id, data: [ confirm: dgettext("prompts", "Are you sure you want to delete this ammo?"), qa: "delete-#{ammo_type.id}" ] do %> <% end %>
<% end %>
<%= if @live_action in [:new, :edit] do %> <.modal return_to={Routes.ammo_type_index_path(Endpoint, :index)}> <.live_component module={CanneryWeb.AmmoTypeLive.FormComponent} id={@ammo_type.id || :new} title={@page_title} action={@live_action} ammo_type={@ammo_type} return_to={Routes.ammo_type_index_path(Endpoint, :index)} current_user={@current_user} } /> <% end %>