cannery/lib/cannery_web/live/ammo_type_live/show.html.heex

133 lines
4.0 KiB
Plaintext

<div class="mx-auto px-4 sm:px-8 space-y-4 max-w-3xl
flex flex-col justify-center items-center">
<h1 class="title text-2xl title-primary-500">
<%= @ammo_type.name %>
</h1>
<%= if @ammo_type.desc do %>
<span
class="max-w-2xl w-full px-8 py-4 rounded-lg
text-center title text-lg
border border-primary-600"
>
<%= @ammo_type.desc %>
</span>
<% end %>
<div class="flex space-x-4 justify-center items-center text-primary-600">
<%= live_patch to: Routes.ammo_type_show_path(Endpoint, :edit, @ammo_type),
class: "text-primary-600 link",
data: [qa: "edit"] do %>
<i class="fa-fw fa-lg fas fa-edit"></i>
<% end %>
<%= link to: "#",
class: "text-primary-600 link",
phx_click: "delete",
data: [
confirm:
dgettext("prompts", "Are you sure you want to delete %{name}?", name: @ammo_type.name),
qa: "delete"
] do %>
<i class="fa-fw fa-lg fas fa-trash"></i>
<% end %>
</div>
<hr class="hr" />
<div class="grid sm:grid-cols-2 text-center justify-center items-center">
<%= for {field_name, field} <- [
{gettext("Bullet type"), :bullet_type},
{gettext("Bullet core"), :bullet_core},
{gettext("Cartridge"), :cartridge},
{gettext("Caliber"), :caliber},
{gettext("Case material"), :case_material},
{gettext("Jacket type"), :jacket_type},
{gettext("Muzzle velocity"), :muzzle_velocity},
{gettext("Powder type"), :powder_type},
{gettext("Powder grains per charge"), :powder_grains_per_charge},
{gettext("Grains"), :grains},
{gettext("Pressure"), :pressure},
{gettext("Primer type"), :primer_type}
] do %>
<%= if @ammo_type |> Map.get(field) do %>
<h3 class="mb-2 sm:mr-4 title text-lg">
<%= field_name %>:
</h3>
<span class="mb-4 sm:mb-2 text-primary-600">
<%= @ammo_type |> Map.get(field) %>
</span>
<% end %>
<% end %>
<%= for {field_name, field} <- [
{"Rimfire", :rimfire},
{"Tracer", :tracer},
{"Incendiary", :incendiary},
{"Blank", :blank},
{"Corrosive", :corrosive}
] do %>
<h3 class="mb-2 sm:mr-4 title text-lg">
<%= field_name %>:
</h3>
<span class="mb-4 sm:mb-2 text-primary-600">
<%= @ammo_type |> Map.get(field) |> humanize() %>
</span>
<% end %>
<%= for {field_name, field} <- [{"Manufacturer", :manufacturer}, {"UPC", :upc}] do %>
<%= if @ammo_type |> Map.get(field) do %>
<h3 class="mb-2 sm:mr-4 title text-lg">
<%= field_name %>:
</h3>
<span class="mb-4 sm:mb-2 text-primary-600">
<%= @ammo_type |> Map.get(field) %>
</span>
<% end %>
<% end %>
<%= if @avg_cost_per_round do %>
<h3 class="mb-2 sm:mr-4 title text-lg">
<%= gettext("Average Price paid") %>:
</h3>
<span class="mb-4 sm:mb-2 text-primary-600">
<%= gettext("$%{amount}",
amount: @avg_cost_per_round |> :erlang.float_to_binary(decimals: 2)
) %>
</span>
<% end %>
</div>
<hr class="hr" />
<div>
<%= if @ammo_groups |> Enum.empty?() do %>
<%= gettext("No ammo for this type") %>
<% else %>
<div class="flex flex-wrap justify-center items-center">
<%= for ammo_group <- @ammo_groups do %>
<.ammo_group_card ammo_group={ammo_group} />
<% end %>
</div>
<% end %>
</div>
</div>
<%= if @live_action in [:edit] do %>
<.modal return_to={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)}>
<.live_component
module={CanneryWeb.AmmoTypeLive.FormComponent}
id={@ammo_type.id}
title={@page_title}
action={@live_action}
ammo_type={@ammo_type}
return_to={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)}
current_user={@current_user}
/>
</.modal>
<% end %>