From ec6b8ba507783a69f2b159446491968ecee62d30 Mon Sep 17 00:00:00 2001 From: Max Veytsman Date: Mon, 27 May 2024 13:23:58 -0400 Subject: [PATCH] Show first name and last initial on rider signup --- .../live/campaign_signup_live/show.ex | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/bike_brigade_web/live/campaign_signup_live/show.ex b/lib/bike_brigade_web/live/campaign_signup_live/show.ex index 1174d879..1b4eb3d7 100644 --- a/lib/bike_brigade_web/live/campaign_signup_live/show.ex +++ b/lib/bike_brigade_web/live/campaign_signup_live/show.ex @@ -74,13 +74,13 @@ defmodule BikeBrigadeWeb.CampaignSignupLive.Show do |> redirect(to: ~p"/campaigns/signup/#{socket.assigns.campaign}") end - defp split_first_name(full_name) do - case String.split(full_name, " ") do + defp first_name_and_last_initial(full_name) do + case String.split(full_name, " ", parts: 2) do [first_name, last_name] when is_binary(first_name) and is_binary(last_name) -> - first_name + "#{first_name} #{String.first(last_name)}" - _ -> - full_name + [first_name] -> + first_name end end @@ -189,7 +189,10 @@ defmodule BikeBrigadeWeb.CampaignSignupLive.Show do
- 1} class="mr-1"> <%= task_item.count %><%= Inflex.inflect(task_item.item.name, task_item.count) %> + 1} class="mr-1"><%= task_item.count %><%= Inflex.inflect( + task_item.item.name, + task_item.count + ) %> <%= task_item.item.description %>
@@ -218,7 +221,7 @@ defmodule BikeBrigadeWeb.CampaignSignupLive.Show do
<%= if @task.assigned_rider do %> - <%= split_first_name(@task.assigned_rider.name) %> + <%= first_name_and_last_initial(@task.assigned_rider.name) %> <.button