defmodule CanneryWeb.Components.ContainerCard do @moduledoc """ Display card for a container """ use CanneryWeb, :component import CanneryWeb.Components.TagCard alias Cannery.{Containers, Repo} alias CanneryWeb.Endpoint def container_card(%{container: container} = assigns) do assigns = assigns |> Map.put(:container, container |> Repo.preload([:tags, :ammo_groups])) ~H"""
<.link navigate={Routes.container_show_path(Endpoint, :show, @container)} class="link">

<%= @container.name %>

<%= if @container.desc do %> <%= gettext("Description:") %> <%= @container.desc %> <% end %> <%= gettext("Type:") %> <%= @container.type %> <%= if @container.location do %> <%= gettext("Location:") %> <%= @container.location %> <% end %> <%= unless @container.ammo_groups |> Enum.empty?() do %> <%= gettext("Packs:") %> <%= @container |> Containers.get_container_ammo_group_count!() %> <%= gettext("Rounds:") %> <%= @container |> Containers.get_container_rounds!() %> <% end %>
<%= unless @container.tags |> Enum.empty?() do %> <%= for tag <- @container.tags do %> <.simple_tag_card tag={tag} /> <% end %> <% end %> <%= if assigns |> Map.has_key?(:tag_actions) do %> <%= render_slot(@tag_actions) %> <% end %>
<%= if assigns |> Map.has_key?(:inner_block) do %>
<%= render_slot(@inner_block) %>
<% end %>
""" end end