2022-02-11 22:47:33 -05:00
|
|
|
defmodule CanneryWeb.Components.AmmoGroupCard do
|
2022-02-05 01:59:40 -05:00
|
|
|
@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"""
|
|
|
|
<div
|
|
|
|
id={"ammo_group-#{@ammo_group.id}"}
|
2022-02-15 18:13:33 -05:00
|
|
|
class="mx-4 my-2 px-8 py-4 flex flex-col justify-center items-center
|
2022-02-05 01:59:40 -05:00
|
|
|
border border-gray-400 rounded-lg shadow-lg hover:shadow-md"
|
|
|
|
>
|
|
|
|
<%= live_redirect to: Routes.ammo_group_show_path(Endpoint, :show, @ammo_group),
|
|
|
|
class: "mb-2 link" do %>
|
|
|
|
<h1 class="title text-xl title-primary-500">
|
|
|
|
<%= @ammo_group.ammo_type.name %>
|
|
|
|
</h1>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
<div class="flex flex-col justify-center items-center">
|
|
|
|
<span class="rounded-lg title text-lg">
|
2022-02-09 00:20:04 -05:00
|
|
|
<%= gettext("Count:") %>
|
|
|
|
<%= @ammo_group.count %>
|
2022-02-05 01:59:40 -05:00
|
|
|
</span>
|
|
|
|
|
|
|
|
<%= if @ammo_group.notes do %>
|
|
|
|
<span class="rounded-lg title text-lg">
|
2022-02-09 00:20:04 -05:00
|
|
|
<%= gettext("Notes:") %>
|
|
|
|
<%= @ammo_group.notes %>
|
2022-02-05 01:59:40 -05:00
|
|
|
</span>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
<%= if @ammo_group.price_paid do %>
|
|
|
|
<span class="rounded-lg title text-lg">
|
2022-02-15 22:33:36 -05:00
|
|
|
<%= gettext("Price paid:") %>
|
|
|
|
<%= gettext("$%{amount}", amount: @ammo_group.price_paid |> :erlang.float_to_binary(decimals: 2)) %>
|
2022-02-05 01:59:40 -05:00
|
|
|
</span>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
2022-02-15 17:33:45 -05:00
|
|
|
|
|
|
|
<%= if assigns |> Map.has_key?(:inner_block) do %>
|
|
|
|
<div class="mt-4 flex space-x-4 justify-center items-center">
|
|
|
|
<%= render_slot(@inner_block) %>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
2022-02-05 01:59:40 -05:00
|
|
|
</div>
|
|
|
|
"""
|
|
|
|
end
|
|
|
|
end
|