diff --git a/lib/cannery_web/components/ammo_group_card.ex b/lib/cannery_web/components/ammo_group_card.ex
index def7c3b6..70165c51 100644
--- a/lib/cannery_web/components/ammo_group_card.ex
+++ b/lib/cannery_web/components/ammo_group_card.ex
@@ -55,13 +55,13 @@ defmodule CanneryWeb.Components.AmmoGroupCard do
<%= gettext("Purchased on:") %>
- <%= @ammo_group.purchased_on |> display_date() %>
+ <.date date={@ammo_group.purchased_on} />
<%= if @ammo_group |> Ammo.get_last_used_shot_group() do %>
<%= gettext("Last used on:") %>
- <%= @ammo_group |> Ammo.get_last_used_shot_group() |> Map.get(:date) |> display_date() %>
+ <.date date={@ammo_group |> Ammo.get_last_used_shot_group() |> Map.get(:date)} />
<% end %>
diff --git a/lib/cannery_web/components/ammo_group_table_component.ex b/lib/cannery_web/components/ammo_group_table_component.ex
index d8aad19e..4bbd7bd2 100644
--- a/lib/cannery_web/components/ammo_group_table_component.ex
+++ b/lib/cannery_web/components/ammo_group_table_component.ex
@@ -157,7 +157,7 @@ defmodule CanneryWeb.Components.AmmoGroupTableComponent do
{purchased_on,
~H"""
- <%= @purchased_on |> display_date() %>
+ <.date date={@purchased_on} />
"""}
end
@@ -173,7 +173,7 @@ defmodule CanneryWeb.Components.AmmoGroupTableComponent do
{last_shot_group_date,
~H"""
<%= if @last_shot_group_date do %>
- <%= @last_shot_group_date |> display_date() %>
+ <.date date={@last_shot_group_date} />
<% else %>
<%= gettext("Never used") %>
<% end %>
diff --git a/lib/cannery_web/components/invite_card.ex b/lib/cannery_web/components/invite_card.ex
index 0aefe182..b29da718 100644
--- a/lib/cannery_web/components/invite_card.ex
+++ b/lib/cannery_web/components/invite_card.ex
@@ -27,8 +27,14 @@ defmodule CanneryWeb.Components.InviteCard do
<%= if @invite.disabled_at |> is_nil() do %>
- <%= gettext("Uses Left:") %>
- <%= @invite.uses_left || "Unlimited" %>
+ <%= if @invite.uses_left do %>
+ <%= gettext(
+ "Uses Left: %{uses_left}",
+ uses_left: @invite.uses_left
+ ) %>
+ <% else %>
+ <%= gettext("Uses Left: Unlimited") %>
+ <% end %>
<% else %>
diff --git a/lib/cannery_web/components/shot_group_table_component.ex b/lib/cannery_web/components/shot_group_table_component.ex
index 08503c2c..b6129b3f 100644
--- a/lib/cannery_web/components/shot_group_table_component.ex
+++ b/lib/cannery_web/components/shot_group_table_component.ex
@@ -103,7 +103,11 @@ defmodule CanneryWeb.Components.ShotGroupTableComponent do
{ammo_type_name, name_block}
end
- defp get_row_value(:date, %{date: date}, _extra_data), do: date |> display_date()
+ defp get_row_value(:date, assigns = %{date: _date}, _extra_data) do
+ ~H"""
+ <.date date={@date} />
+ """
+ end
defp get_row_value(:actions, shot_group, %{actions: actions}) do
assigns = %{actions: actions, shot_group: shot_group}
diff --git a/lib/cannery_web/components/user_card.ex b/lib/cannery_web/components/user_card.ex
index 20039118..5daba522 100644
--- a/lib/cannery_web/components/user_card.ex
+++ b/lib/cannery_web/components/user_card.ex
@@ -23,16 +23,23 @@ defmodule CanneryWeb.Components.UserCard do
- <%= if @user.confirmed_at |> is_nil() do %>
- Email unconfirmed
+ <%= if @user.confirmed_at do %>
+ <%= gettext(
+ "User was confirmed at%{confirmed_datetime}",
+ confirmed_datetime: ""
+ ) %>
+ <.datetime datetime={@user.confirmed_at} />
<% else %>
- User was confirmed at <%= @user.confirmed_at |> display_datetime() %>
+ <%= gettext("Email unconfirmed") %>
<% end %>
- <%= gettext("User registered on") %>
- <%= @user.inserted_at |> display_datetime() %>
+ <%= gettext(
+ "User registered on%{registered_datetime}",
+ registered_datetime: ""
+ ) %>
+ <.datetime datetime={@user.inserted_at} />
diff --git a/lib/cannery_web/live/ammo_group_live/show.ex b/lib/cannery_web/live/ammo_group_live/show.ex
index 9c4164aa..06de2eb7 100644
--- a/lib/cannery_web/live/ammo_group_live/show.ex
+++ b/lib/cannery_web/live/ammo_group_live/show.ex
@@ -116,7 +116,12 @@ defmodule CanneryWeb.AmmoGroupLive.Show do
value =
case key do
:date ->
- {date, date |> display_date()}
+ assigns = %{date: date}
+
+ {date,
+ ~H"""
+ <.date date={@date} />
+ """}
:actions ->
~H"""
diff --git a/lib/cannery_web/live/ammo_group_live/show.html.heex b/lib/cannery_web/live/ammo_group_live/show.html.heex
index e538db43..147b68dd 100644
--- a/lib/cannery_web/live/ammo_group_live/show.html.heex
+++ b/lib/cannery_web/live/ammo_group_live/show.html.heex
@@ -28,7 +28,7 @@
<%= gettext("Purchased on:") %>
- <%= @ammo_group.purchased_on |> display_date() %>
+ <.date date={@ammo_group.purchased_on} />
<%= if @ammo_group.price_paid do %>
diff --git a/lib/cannery_web/live/ammo_type_live/show.html.heex b/lib/cannery_web/live/ammo_type_live/show.html.heex
index 54cafcfb..3dcdc5d0 100644
--- a/lib/cannery_web/live/ammo_type_live/show.html.heex
+++ b/lib/cannery_web/live/ammo_type_live/show.html.heex
@@ -124,7 +124,7 @@
- <%= @ammo_type.inserted_at |> display_datetime() %>
+ <.datetime datetime={@ammo_type.inserted_at} />
<%= if @avg_cost_per_round do %>
diff --git a/lib/cannery_web/views/view_helpers.ex b/lib/cannery_web/views/view_helpers.ex
index 27dbf882..7e0c8874 100644
--- a/lib/cannery_web/views/view_helpers.ex
+++ b/lib/cannery_web/views/view_helpers.ex
@@ -5,64 +5,62 @@ defmodule CanneryWeb.ViewHelpers do
:view`
"""
- import Phoenix.Component
-
- @id_length 16
+ use Phoenix.Component
@doc """
- Returns a