Skip to content

Commit

Permalink
fix: edit stop broken after dependency update
Browse files Browse the repository at this point in the history
  • Loading branch information
Whoops committed Nov 1, 2024
1 parent ff9581a commit 813cf08
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions lib/arrow_web/live/stop_live/stop_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,13 @@ defmodule ArrowWeb.StopViewLive do
def mount(_params, session, socket) do
logout_url = session["logout_url"]
form = to_form(Stops.change_stop(%Stop{}))
stops = Stops.list_stops()

socket =
socket
|> assign(:form, form)
|> assign(:form_action, "create")
|> assign(:http_action, ~p"/stops")
|> assign(:stops, stops)
|> assign(:stop, %Stop{})
|> assign(:title, "create shuttle stop")
|> assign(:stop_map_props, %{})
|> assign(:logout_url, logout_url)
Expand All @@ -130,7 +129,7 @@ defmodule ArrowWeb.StopViewLive do
end

def handle_event("validate", %{"stop" => stop_params}, socket) do
form = Stops.change_stop(%Stop{}, stop_params) |> to_form(action: :validate)
form = Stops.change_stop(socket.assigns.stop, stop_params) |> to_form(action: :validate)

{:noreply,
socket
Expand Down
2 changes: 1 addition & 1 deletion lib/arrow_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ defmodule ArrowWeb.Router do
live("/stops/new", StopViewLive, :new)
live("/stops/:id/edit", StopViewLive, :edit)
get("/stops", StopController, :index)
post("/stops/:id", StopController, :update)
put("/stops/:id", StopController, :update)
post("/stops", StopController, :create)
resources("/shapes", ShapeController, only: [:delete, :index, :show])
get("/shapes_upload", ShapeController, :new)
Expand Down
2 changes: 1 addition & 1 deletion test/arrow_web/live/stop_live/stop_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ defmodule ArrowWeb.StopLiveTest do
conn = follow_trigger_action(form, conn)
assert conn.method == "POST"
params = Enum.map(@update_attrs, fn {k, v} -> {"#{k}", v} end) |> Enum.into(%{})
assert conn.params == %{"stop" => params, "id" => "#{stop.id}"}
assert conn.params == %{"stop" => params}
end

@tag :authenticated_admin
Expand Down

0 comments on commit 813cf08

Please sign in to comment.