From e0f91efb83b716dd53a73eb2737e65572ad1d540 Mon Sep 17 00:00:00 2001 From: Max Veytsman Date: Mon, 17 Jun 2024 17:43:30 -0400 Subject: [PATCH] Show first name and last initial on rider signup (#377) --- .../live/campaign_signup_live/show.ex | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 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 8a7de720..7ebb9fc1 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,13 +221,12 @@ 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) %>
You
- <.button :if={task_eligigle_for_unassign(@task, @campaign, @current_rider_id)} phx-click={JS.push("unassign_task", value: %{task_id: @task.id})}