Skip to content

Commit

Permalink
Show first name and last initial on rider signup (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
mveytsman authored Jun 17, 2024
1 parent 3cfae80 commit e0f91ef
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/bike_brigade_web/live/campaign_signup_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -189,7 +189,10 @@ defmodule BikeBrigadeWeb.CampaignSignupLive.Show do
<div class="flex items-center">
<details>
<summary class="cursor-pointer" title={task_item.item.description}>
<span :if={task_item.count > 1} class="mr-1"> <%= task_item.count %></span><%= Inflex.inflect(task_item.item.name, task_item.count) %>
<span :if={task_item.count > 1} class="mr-1"><%= task_item.count %></span><%= Inflex.inflect(
task_item.item.name,
task_item.count
) %>
</summary>
<%= task_item.item.description %>
</details>
Expand Down Expand Up @@ -218,13 +221,12 @@ defmodule BikeBrigadeWeb.CampaignSignupLive.Show do
<div class="flex flex-col space-y-2 md:items-center md:space-y-0 md:flex-row md:space-x-2">
<%= if @task.assigned_rider do %>
<div :if={@task.assigned_rider.id != @current_rider_id}>
<%= split_first_name(@task.assigned_rider.name) %>
<%= first_name_and_last_initial(@task.assigned_rider.name) %>
</div>
<div :if={@task.assigned_rider.id == @current_rider_id}>
You
</div>
<.button
:if={task_eligigle_for_unassign(@task, @campaign, @current_rider_id)}
phx-click={JS.push("unassign_task", value: %{task_id: @task.id})}
Expand Down

0 comments on commit e0f91ef

Please sign in to comment.