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

<%= @container.name %>

<% end %> <%= if @container.desc do %> <%= gettext("Description:") %> <%= @container.desc %> <% end %> <%= gettext("Type:") %> <%= @container.type %> <%= if @container.location do %> <%= gettext("Location:") %> <%= @container.location %> <% end %> <%= if @container.ammo_groups do %> <%= 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