Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show first name and last initial on rider signup #377

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading