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

Add: signup_notes, rename rider_notes. #385

Merged
merged 1 commit into from
Jun 19, 2024
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
2 changes: 1 addition & 1 deletion lib/bike_brigade/delivery.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

alias BikeBrigade.History
alias BikeBrigade.Messaging
alias BikeBrigade.Delivery.{Task, CampaignRider, TaskAssignmentLog}

Check warning on line 12 in lib/bike_brigade/delivery.ex

View workflow job for this annotation

GitHub Actions / Build and test

unused alias TaskAssignmentLog

Check warning on line 12 in lib/bike_brigade/delivery.ex

View workflow job for this annotation

GitHub Actions / Build and test

unused alias TaskAssignmentLog

import BikeBrigade.Utils, only: [task_count: 1, humanized_task_count: 1]

Expand Down Expand Up @@ -638,7 +638,7 @@

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 @@ -9,7 +9,7 @@
alias BikeBrigade.Delivery.{Campaign, Item, TaskItem}
alias BikeBrigade.Locations.Location

defenum(DeliveryStatusEnum,

Check warning on line 12 in lib/bike_brigade/delivery/task.ex

View workflow job for this annotation

GitHub Actions / Build and test

the underscored variable "_t" is used after being set. A leading underscore indicates that the value of the variable should be ignored. If this is intended please rename the variable to remove the underscore

Check warning on line 12 in lib/bike_brigade/delivery/task.ex

View workflow job for this annotation

GitHub Actions / Build and test

the underscored variable "_t" is used after being set. A leading underscore indicates that the value of the variable should be ignored. If this is intended please rename the variable to remove the underscore
pending: "pending",
picked_up: "picked_up",
completed: "completed",
Expand All @@ -23,7 +23,8 @@
: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 @@
: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 @@
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 Expand Up @@ -102,7 +102,7 @@

def item_name(%Task{task_items: [%{item: %{name: item_name}}]}), do: item_name

defp to_uri(location) do

Check warning on line 105 in test/bike_brigade/delivery_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

function to_uri/1 is unused
location
|> String.Chars.to_string()
|> URI.encode_www_form()
Expand Down
Loading