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 item name and description in signup #372

Merged
Show file tree
Hide file tree
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
41 changes: 15 additions & 26 deletions lib/bike_brigade_web/live/campaign_signup_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -183,37 +183,26 @@ defmodule BikeBrigadeWeb.CampaignSignupLive.Show do
## Module specific components

defp get_delivery_size(assigns) do
item_list =
Enum.map(assigns.task.task_items, fn task_item ->
"#{task_item.count} #{task_item.item.category}"
end)

assigns = assign(assigns, :item_list, item_list)

~H"""
<div :for={item <- @item_list}>
<%= item %>
<div :for={task_item <- @task.task_items} class="flex items-center">
<span :if={task_item.count > 1}> task_item.count </span>

<%= if task_item.item.description && task_item.item.description != "" do %>
<div class="flex items-center">
<details>
<summary class="cursor-pointer" title={task_item.item.description}>
<%= Inflex.inflect(task_item.item.name, task_item.count) %>
</summary>
<%= task_item.item.description %>
</details>
</div>
<% else %>
<%= Inflex.inflect(task_item.item.name, task_item.count) %>
<% end %>
</div>
"""
end

defp truncated_riders_notes(assigns) do
if String.length(assigns.note) > 40 do
~H"""
<div class="w-[40ch] flex items-center">
<details>
<summary class="cursor-pointer"><%= String.slice(@note, 0..40) %>...</summary>
<%= @note %>
</details>
</div>
"""
else
~H"""
<div><%= @note %></div>
"""
end
end

@doc """
Shows one of the following:
- A "Sign up" button if the campaign is eligible for signing up
Expand Down
9 changes: 2 additions & 7 deletions lib/bike_brigade_web/live/campaign_signup_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<:col :let={_task} label="Pickup time">
<%= pickup_window(@campaign) %>
</:col>
<:col :let={task} label="Delivery Size">
<:col :let={task} label="Delivery">
<.get_delivery_size task={task} />
</:col>
<:col :let={task} label="Recipient"><%= initials(task.dropoff_name) %></:col>
Expand All @@ -42,7 +42,7 @@
</div>
<div class="flex flex-col bg-white shadow">
<div class="flex items-center p-4 py-2 border-b">
<span class="pr-2 ">Delivery size:</span>
<span class="pr-2 ">Delivery:</span>
<span class="italic">
<.get_delivery_size task={t} />
</span>
Expand All @@ -53,11 +53,6 @@
<span><%= Locations.neighborhood(t.dropoff_location) %></span>
</div>

<div :if={t.rider_notes} class="flex flex-col justify-center px-4 py-2 border-b-2">
<span>Notes:</span>
<span><%= t.rider_notes %></span>
</div>

<div class="flex flex-col justify-center px-4 py-2 border-b-2">
<.signup_button
id="signup-btn-mobile"
Expand Down
5 changes: 5 additions & 0 deletions test/bike_brigade_web/live/campaign_signup_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ defmodule BikeBrigadeWeb.CampaignSignupLiveTest do

assert live |> element("[data-test-id=dropoff-name-#{ctx.task.id}]") |> render =~ "CJH"
assert html =~ BikeBrigade.Locations.neighborhood(ctx.task.dropoff_location)

# We show the name and description of the item
assert html =~ "Burrito"
assert html =~ "a large burrito with all the fixings"

end

test "Invalid route for campaign shows flash and redirects", ctx do
Expand Down
7 changes: 3 additions & 4 deletions test/support/fixtures.ex
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,9 @@ defmodule BikeBrigade.Fixtures do

defp fake_item() do
%{
name: "Foodshare Box",
plural: "Foodshare Boxes",
description: "a box",
category: "Foodshare Box"
name: "Burrito",
description: "a large burrito with all the fixings",
category: "Prepared Food"
}
end
end
Loading