Skip to content

Commit

Permalink
Can now create alert on application search results page
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Oct 24, 2023
1 parent 852aefa commit b8dedf2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def address
render "address"
else
@full_address = T.let(top.full_address, T.nilable(String))
@alert = Alert.new(address: @q, user: User.new)
@alert = Alert.new(address: @q, user: User.new, radius_meters: Alert::DEFAULT_RADIUS)
@other_addresses = T.must(result.rest).map(&:full_address)
point = RGeo::Geographic.spherical_factory.point(top.lng, top.lat)
@applications = Application.select("*", "ST_Distance(lonlat, '#{point}')/1000 AS distance")
Expand Down
1 change: 1 addition & 0 deletions app/views/_tailwind/alerts_new/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<%= b.label class: "ml-3 text-navy text-2xl" %>
</div>
<% end %>
<%= f.error :radius_meters, class: "mt-5" %>
</fieldset>

<div class="mt-12">
Expand Down
6 changes: 4 additions & 2 deletions app/views/_tailwind/applications/_create_alert_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
<%= image_tag "tailwind/bookmark.svg" %>
<p class="text-2xl font-bold text-navy">Save this search as an email alert</p>
</div>
<%= render Tailwind::ButtonComponent.new(tag: :button, size: "2xl", type: :primary) do %>
Save
<%= form_with model: [:profile, alert], builder: FormBuilders::Tailwind do |f| %>
<%= f.hidden_field :address %>
<%= f.hidden_field :radius_meters %>
<%= f.button "Save" %>
<% end %>
</div>
<% else %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/_tailwind/applications/address.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<%= render "pagination", applications: @applications %>

<div class="mt-12 mb-4">
<%= render "create_alert_form" %>
<%= render "create_alert_form", alert: @alert %>
</div>

<%# TODO: Add "save this search" here %>
Expand All @@ -30,7 +30,7 @@
</ul>

<div class="mt-12 mb-4">
<%= render "create_alert_form" %>
<%= render "create_alert_form", alert: @alert %>
</div>

<%= render "pagination", applications: @applications %>
Expand Down

0 comments on commit b8dedf2

Please sign in to comment.