<%= gettext("Ammo") %>

<%= cond do %> <% @containers_count == 0 -> %>

<%= dgettext("prompts", "You'll need to") %>

<.link navigate={Routes.container_index_path(Endpoint, :new)} class="btn btn-primary"> <%= dgettext("actions", "add a container first") %>
<% @types_count == 0 -> %>

<%= dgettext("prompts", "You'll need to") %>

<.link navigate={Routes.type_index_path(Endpoint, :new)} class="btn btn-primary"> <%= dgettext("actions", "add a type first") %>
<% @packs_count == 0 -> %>

<%= gettext("No ammo") %> <%= display_emoji("😔") %>

<.link patch={Routes.pack_index_path(Endpoint, :new)} class="btn btn-primary"> <%= dgettext("actions", "Add your first box!") %> <% true -> %> <.link patch={Routes.pack_index_path(Endpoint, :new)} class="btn btn-primary"> <%= dgettext("actions", "Add Ammo") %>
<.form :let={f} for={%{}} as={:type} phx-change="change_class" phx-submit="change_class" class="flex items-center" > <%= label(f, :class, gettext("Class"), class: "title text-primary-600 text-lg text-center" ) %> <%= select( f, :class, [ {gettext("All"), :all}, {gettext("Rifle"), :rifle}, {gettext("Shotgun"), :shotgun}, {gettext("Pistol"), :pistol} ], class: "mx-2 my-1 min-w-md input input-primary", value: @class ) %> <.form :let={f} for={%{}} as={:search} phx-change="search" phx-submit="search" class="grow flex items-center" > <%= text_input(f, :search_term, class: "grow input input-primary", value: @search, role: "search", phx_debounce: 300, placeholder: gettext("Search ammo") ) %> <.toggle_button action="toggle_show_used" value={@show_used}> <%= gettext("Show used") %>
<%= if @packs |> Enum.empty?() do %>

<%= gettext("No Ammo") %> <%= display_emoji("😔") %>

<% else %> <.live_component module={CanneryWeb.Components.PackTableComponent} id="pack-index-table" packs={@packs} current_user={@current_user} show_used={@show_used} > <:type :let={%{name: type_name} = type}> <.link navigate={Routes.type_show_path(Endpoint, :show, type)} class="link"> <%= type_name %> <:range :let={pack}>
<.link patch={Routes.pack_index_path(Endpoint, :add_shot_record, pack)} class="mx-2 my-1 text-sm btn btn-primary" > <%= dgettext("actions", "Record shots") %>
<:container :let={{pack, %{name: container_name} = container}}>
<.link navigate={Routes.container_show_path(Endpoint, :show, container)} class="mx-2 my-1 link" > <%= container_name %> <.link patch={Routes.pack_index_path(Endpoint, :move, pack)} class="mx-2 my-1 text-sm btn btn-primary" > <%= dgettext("actions", "Move ammo") %>
<:actions :let={%{count: pack_count} = pack}>
<.link navigate={Routes.pack_show_path(Endpoint, :show, pack)} class="text-primary-600 link" aria-label={ dgettext("actions", "View pack of %{pack_count} bullets", pack_count: pack_count) } > <.link patch={Routes.pack_index_path(Endpoint, :edit, pack)} class="text-primary-600 link" aria-label={ dgettext("actions", "Edit pack of %{pack_count} bullets", pack_count: pack_count) } > <.link patch={Routes.pack_index_path(Endpoint, :clone, pack)} class="text-primary-600 link" aria-label={ dgettext("actions", "Clone pack of %{pack_count} bullets", pack_count: pack_count ) } > <.link href="#" class="text-primary-600 link" phx-click="delete" phx-value-id={pack.id} data-confirm={dgettext("prompts", "Are you sure you want to delete this ammo?")} aria-label={ dgettext("actions", "Delete pack of %{pack_count} bullets", pack_count: pack_count ) } >
<% end %> <% end %>
<%= case @live_action do %> <% create when create in [:new, :edit, :clone] -> %> <.modal return_to={Routes.pack_index_path(Endpoint, :index)}> <.live_component module={CanneryWeb.PackLive.FormComponent} id={@pack.id || :new} title={@page_title} action={@live_action} pack={@pack} return_to={Routes.pack_index_path(Endpoint, :index)} current_user={@current_user} /> <% :add_shot_record -> %> <.modal return_to={Routes.pack_index_path(Endpoint, :index)}> <.live_component module={CanneryWeb.Components.AddShotRecordComponent} id={:new} title={@page_title} action={@live_action} pack={@pack} return_to={Routes.pack_index_path(Endpoint, :index)} current_user={@current_user} /> <% :move -> %> <.modal return_to={Routes.pack_index_path(Endpoint, :index)}> <.live_component module={CanneryWeb.Components.MovePackComponent} id={@pack.id} title={@page_title} action={@live_action} pack={@pack} return_to={Routes.pack_index_path(Endpoint, :index)} current_user={@current_user} /> <% _ -> %> <% end %>