<%= gettext("Range day") %>

<%= if @packs |> Enum.empty?() do %>

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

<.link navigate={Routes.pack_index_path(Endpoint, :index)} class="btn btn-primary"> <%= dgettext("actions", "Why not get some ready to shoot?") %> <% else %> <.link navigate={Routes.pack_index_path(Endpoint, :index)} class="btn btn-primary"> <%= dgettext("actions", "Stage ammo") %>
<.pack_card :for={%{id: pack_id} = pack <- @packs} pack={pack} original_count={Map.fetch!(@original_counts, pack_id)} cpr={Map.get(@cprs, pack_id)} last_used_date={Map.get(@last_used_dates, pack_id)} current_user={@current_user} > <.link patch={Routes.range_index_path(Endpoint, :add_shot_record, pack)} class="btn btn-primary" > <%= dgettext("actions", "Record shots") %>
<% end %>
<%= if @shot_record_count == 0 do %>

<%= gettext("No shots recorded") %> <%= display_emoji("😔") %>

<% else %>

<%= gettext("Shot log") %>

<%= dgettext("errors", "Your browser does not support the canvas element.") %>
<.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 shot records") ) %>
<%= if @shot_records |> Enum.empty?() do %>

<%= gettext("No shots recorded") %> <%= display_emoji("😔") %>

<% else %> <.live_component module={CanneryWeb.Components.ShotRecordTableComponent} id="shot_records_index_table" shot_records={@shot_records} current_user={@current_user} > <:actions :let={shot_record}>
<.link patch={Routes.range_index_path(Endpoint, :edit, shot_record)} class="text-primary-600 link" aria-label={ dgettext("actions", "Edit shot record of %{shot_record_count} shots", shot_record_count: shot_record.count ) } > <.link href="#" class="text-primary-600 link" phx-click="delete" phx-value-id={shot_record.id} data-confirm={ dgettext("prompts", "Are you sure you want to delete this shot record?") } aria-label={ dgettext("actions", "Delete shot record of %{shot_record_count} shots", shot_record_count: shot_record.count ) } >
<% end %> <% end %>
<%= case @live_action do %> <% :edit -> %> <.modal return_to={Routes.range_index_path(Endpoint, :index)}> <.live_component module={CanneryWeb.RangeLive.FormComponent} id={@shot_record.id} title={@page_title} action={@live_action} shot_record={@shot_record} return_to={Routes.range_index_path(Endpoint, :index)} current_user={@current_user} /> <% :add_shot_record -> %> <.modal return_to={Routes.range_index_path(Endpoint, :index)}> <.live_component module={CanneryWeb.Components.AddShotRecordComponent} id={:new} title={@page_title} action={@live_action} pack={@pack} return_to={Routes.range_index_path(Endpoint, :index)} current_user={@current_user} /> <% _ -> %> <% end %>