defmodule CanneryWeb.Components.AmmoGroupCard do @moduledoc """ Display card for an ammo group """ use CanneryWeb, :component alias Cannery.Repo alias CanneryWeb.Endpoint def ammo_group_card(assigns) do assigns = assigns |> assign(:ammo_group, assigns.ammo_group |> Repo.preload(:ammo_type)) ~H"""
<%= live_redirect to: Routes.ammo_group_show_path(Endpoint, :show, @ammo_group), class: "mb-2 link" do %>

<%= @ammo_group.ammo_type.name %>

<% end %>
<%= gettext("Count:") %> <%= @ammo_group.count %> <%= if @ammo_group.notes do %> <%= gettext("Notes:") %> <%= @ammo_group.notes %> <% end %> <%= if @ammo_group.price_paid do %> <%= gettext("Price paid:") %> $ <%= @ammo_group.price_paid |> :erlang.float_to_binary(decimals: 2) %> <% end %>
<%= if assigns |> Map.has_key?(:inner_block) do %>
<%= render_slot(@inner_block) %>
<% end %>
""" end end