Skip to content

Commit

Permalink
Add: signup_notes, rename rider_notes. (#385)
Browse files Browse the repository at this point in the history
add: add signup_notes, rename rider_notes.

This was done so that we could include signup related information when
riders signup for a delivery.

It has also been on the backlog to rename "rider_notes" to "delivery_instructions"
  • Loading branch information
teesloane authored Jun 19, 2024
1 parent bf4fec8 commit 8e2de46
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/bike_brigade/delivery.ex
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ defmodule BikeBrigade.Delivery do

task_details =
for task <- tasks do
"Name: #{task.dropoff_name}\nPhone: #{task.dropoff_phone}\nType: #{BikeBrigadeWeb.CampaignHelpers.request_type(task)}\nAddress: #{task.dropoff_location}\nNotes: #{task.rider_notes}"
"Name: #{task.dropoff_name}\nPhone: #{task.dropoff_phone}\nType: #{BikeBrigadeWeb.CampaignHelpers.request_type(task)}\nAddress: #{task.dropoff_location}\nNotes: #{task.delivery_instructions}"
end
|> Enum.join("\n\n")

Expand Down
7 changes: 4 additions & 3 deletions lib/bike_brigade/delivery/task.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ defmodule BikeBrigade.Delivery.Task do
:delivery_status,
:delivery_status_notes,
:partner_tracking_id,
:rider_notes,
:delivery_instructions,
:signup_notes,
:assigned_rider_id,
:campaign_id
]
Expand All @@ -33,8 +34,8 @@ defmodule BikeBrigade.Delivery.Task do
:dropoff_location
]
schema "tasks" do
# TODO: rename to delivery_instructions
field :rider_notes, :string
field :delivery_instructions, :string
field :signup_notes, :string

field :dropoff_name, :string
field :dropoff_phone, EctoPhoneNumber.Canadian
Expand Down
4 changes: 2 additions & 2 deletions lib/bike_brigade/gsheets_importer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ defmodule BikeBrigade.GSheetsImporter do
dropoff_name: name,
dropoff_phone: phone,
dropoff_location: %{address: street, postal: postal},
rider_notes: notes,
delivery_instructions: notes,
delivery_status: :pending,
partner_tracking_id: partner_tracking_id,
task_items: [%{count: count, item_id: item_id}]
Expand Down Expand Up @@ -204,7 +204,7 @@ defmodule BikeBrigade.GSheetsImporter do
dropoff_name: name,
dropoff_phone: phone,
dropoff_location: %{address: street, postal: postal},
rider_notes: notes,
delivery_instructions: notes,
delivery_status: :pending,
partner_tracking_id: partner_tracking_id,
task_items: task_items
Expand Down
2 changes: 1 addition & 1 deletion lib/bike_brigade_web/controllers/campaign_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ defmodule BikeBrigadeWeb.CampaignController do
task.dropoff_location,
task.dropoff_phone,
CampaignHelpers.request_type(task),
task.rider_notes
task.delivery_instructions
]
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,16 @@
</.link>
</div>

<.input type="textarea" field={{f, :rider_notes}} label="Notes" />
<.input
type="textarea"
field={{f, :delivery_instructions}}
label="Delivery Instructions (sent to rider when doing delivery)"
/>
<.input
type="textarea"
field={{f, :signup_notes}}
label="Signup Notes (shown on rider signup - No personal information in this notes, please!)"
/>

<:actions>
<.button type="submit" phx-disable-with="Saving...">Save</.button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<div class="flex flex-row my-2">
<Heroicons.pencil_square mini class="flex-shrink-0 w-4 h-4 text-gray-500" />
<div class="mx-1 text-sm leading-5 text-gray-600">
<span class="pii"><%= task.rider_notes %></span>
<span class="pii"><%= task.delivery_instructions %></span>
</div>
</div>
<div class="flex flex-row my-2">
Expand Down
14 changes: 12 additions & 2 deletions lib/bike_brigade_web/live/campaign_signup_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<:col :let={task} label="Dropoff Neighbourhood">
<%= Locations.neighborhood(task.dropoff_location) %>
</:col>

<:col :let={task} label="Signup Notes">
<%= task.signup_notes %>
</:col>
<:action :let={task}>
<.signup_button
id="signup-btn-desktop"
Expand All @@ -33,7 +37,9 @@
</:action>
</.table>
</section>

<!-- Mobile list of tasks -->

<ul class="flex flex-col text-xs md:hidden">
<li :for={t <- @tasks} class="w-full mb-8">
<div class="flex justify-between px-4 py-3 font-bold bg-slate-200">
Expand All @@ -42,16 +48,20 @@
</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:</span>
<span class="pr-2 font-semibold">Delivery:</span>
<span class="italic">
<.get_delivery_size task={t} />
</span>
</div>

<div class="flex items-start px-4 py-2 space-x-2 border-b">
<span>Dropoff Neighbourhood:</span>
<span class="font-semibold">Dropoff Neighbourhood:</span>
<span><%= Locations.neighborhood(t.dropoff_location) %></span>
</div>
<div :if={t.signup_notes} class="flex items-start px-4 py-2 space-x-2 border-b">
<span class="font-semibold">Signup Notes</span>
<span><%= t.signup_notes %></span>
</div>

<div class="flex flex-col justify-center px-4 py-2 border-b-2">
<.signup_button
Expand Down
4 changes: 2 additions & 2 deletions lib/bike_brigade_web/live/delivery_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@
class="relative mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-7"
>
<div x-bind:class="{ 'max-h-24': collapsed }" class="overflow-hidden">
<%= if is_nil(task.rider_notes) or task.rider_notes=="" do %>
<%= if is_nil(task.delivery_instructions) or task.delivery_instructions=="" do %>
N/A
<% else %>
<%= render_raw(task.rider_notes) %>
<%= render_raw(task.delivery_instructions) %>
<% end %>
</div>
<div
Expand Down
2 changes: 1 addition & 1 deletion lib/bike_brigade_web/live/sms_message_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ defmodule BikeBrigadeWeb.SmsMessageLive.Index do

defp details_buffer(campaign) do
for task <- campaign.tasks do
"Name: #{task.dropoff_name}\nPhone: #{task.dropoff_phone}\nType: #{request_type(task)}\nAddress: #{task.dropoff_location}\nNotes: #{task.rider_notes}"
"Name: #{task.dropoff_name}\nPhone: #{task.dropoff_phone}\nType: #{request_type(task)}\nAddress: #{task.dropoff_location}\nNotes: #{task.delivery_instructions}"
end
|> Enum.join("\n\n")
|> inspect()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
defmodule BikeBrigade.Repo.Migrations.AddSignupNotesAndRenameRiderNotes do
use Ecto.Migration

def change do
alter table(:tasks) do
add :signup_notes, :text
end

rename table(:tasks), :rider_notes, to: :delivery_instructions
end
end
2 changes: 1 addition & 1 deletion test/bike_brigade/delivery_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ defmodule BikeBrigade.DeliveryTest do
Phone: #{task.dropoff_phone}
Type: 1 #{item_name(task)}
Address: #{task.dropoff_location}
Notes: #{task.rider_notes}
Notes: #{task.delivery_instructions}
Directions: #{directions_url}
"""
Expand Down

0 comments on commit 8e2de46

Please sign in to comment.