diff --git a/lib/cannery_web/components/move_ammo_group_component.ex b/lib/cannery_web/components/move_ammo_group_component.ex index 81fc2ec1..b3a49ba1 100644 --- a/lib/cannery_web/components/move_ammo_group_component.ex +++ b/lib/cannery_web/components/move_ammo_group_component.ex @@ -4,7 +4,7 @@ defmodule CanneryWeb.Components.MoveAmmoGroupComponent do """ use CanneryWeb, :live_component - alias Cannery.{Accounts.User, Ammo, Ammo.AmmoGroup, Containers} + alias Cannery.{Accounts.User, Ammo, Ammo.AmmoGroup, Containers, Containers.Container} alias CanneryWeb.Endpoint alias Phoenix.LiveView.Socket @@ -28,7 +28,12 @@ defmodule CanneryWeb.Components.MoveAmmoGroupComponent do Containers.list_containers(current_user) |> Enum.reject(fn %{id: id} -> id == container_id end) - {:ok, socket |> assign(assigns) |> assign(changeset: changeset, containers: containers)} + socket = + socket + |> assign(assigns) + |> assign(changeset: changeset, containers: containers) + + {:ok, socket} end @impl true @@ -55,4 +60,82 @@ defmodule CanneryWeb.Components.MoveAmmoGroupComponent do {:noreply, socket} end + + @impl true + def render(%{containers: containers} = assigns) do + columns = [ + %{label: gettext("Container"), key: "name"}, + %{label: gettext("Type"), key: "type"}, + %{label: gettext("Location"), key: "location"}, + %{ + label: nil, + key: "actions", + sortable: false, + class: "px-4 py-2 space-x-4 flex justify-center items-center" + } + ] + + rows = containers |> get_rows_for_containers(assigns, columns) + + assigns = assigns |> Map.merge(%{columns: columns, rows: rows}) + + ~H""" +
- <%= gettext("Container") %> - | - -- <%= gettext("Type") %> - | - -- <%= gettext("Location") %> - | - -- |
---|---|---|---|
- <%= container.name %> - | - -- <%= container.type %> - | - -- <%= container.location %> - | - -
-
-
-
- |
-