<%= @ammo_type.name %>

<%= if @ammo_type.desc do %> <%= @ammo_type.desc %> <% end %>
<%= live_patch to: Routes.ammo_type_show_path(Endpoint, :edit, @ammo_type), class: "text-primary-600 link", data: [qa: "edit"] do %> <% end %> <%= link to: "#", class: "text-primary-600 link", phx_click: "delete", data: [ confirm: dgettext("prompts", "Are you sure you want to delete %{name}? This will delete all %{name} type ammo as well!", name: @ammo_type.name), qa: "delete" ] do %> <% end %>

<%= for {field_name, field, type} <- [ {gettext("Bullet type"), :bullet_type, :string}, {gettext("Bullet core"), :bullet_core, :string}, {gettext("Cartridge"), :cartridge, :string}, {gettext("Caliber"), :caliber, :string}, {gettext("Case material"), :case_material, :string}, {gettext("Jacket type"), :jacket_type, :string}, {gettext("Muzzle velocity"), :muzzle_velocity, :string}, {gettext("Powder type"), :powder_type, :string}, {gettext("Powder grains per charge"), :powder_grains_per_charge, :string}, {gettext("Grains"), :grains, :string}, {gettext("Pressure"), :pressure, :string}, {gettext("Primer type"), :primer_type, :string}, {gettext("Firing type"), :firing_type, :string}, {gettext("Tracer"), :tracer, :boolean}, {gettext("Incendiary"), :incendiary, :boolean}, {gettext("Blank"), :blank, :boolean}, {gettext("Corrosive"), :corrosive, :boolean}, {gettext("Manufacturer"), :manufacturer, :string}, {gettext("UPC"), :upc, :string} ] do %> <%= if @ammo_type |> Map.get(field) do %>

<%= field_name %>:

<%= case type do %> <% :boolean -> %> <%= @ammo_type |> Map.get(field) |> humanize() %> <% _ -> %> <%= @ammo_type |> Map.get(field) %> <% end %> <% end %> <% end %>

<%= gettext("Current # of rounds:") %>

<%= @ammo_type |> Ammo.get_round_count_for_ammo_type(@current_user) %>

<%= gettext("Total rounds shot:") %>

<%= @ammo_type |> Ammo.get_used_count_for_ammo_type(@current_user) %>

<%= gettext("Added on:") %>

<%= @ammo_type.inserted_at |> display_datetime() %> <%= if @avg_cost_per_round do %>

<%= gettext("Average Price paid") %>:

<%= gettext("$%{amount}", amount: @avg_cost_per_round |> :erlang.float_to_binary(decimals: 2) ) %> <% else %>

<%= gettext("No cost information") %>

<% end %>

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

<%= gettext("No ammo for this type") %> <%= display_emoji("😔") %>

<% else %>
<%= for ammo_group <- @ammo_groups do %> <.ammo_group_card ammo_group={ammo_group} /> <% end %>
<% end %>
<%= if @live_action in [:edit] do %> <.modal return_to={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)}> <.live_component module={CanneryWeb.AmmoTypeLive.FormComponent} id={@ammo_type.id} title={@page_title} action={@live_action} ammo_type={@ammo_type} return_to={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)} current_user={@current_user} /> <% end %>