Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions lib/pears_web/components/add_pear_form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ defmodule PearsWeb.AddPearForm do
def handle_event("add_pear", %{"pear-name" => pear_name}, socket) do
case Pears.add_pear(socket.assigns.team.name, pear_name) do
{:ok, _} ->
{:noreply, push_redirect(socket, to: ~p"/")}
{:noreply, push_navigate(socket, to: ~p"/")}

{:error, _} ->
{:noreply,
socket
|> put_flash(:error, "Sorry, a Pear with the name '#{pear_name}' already exists")
|> push_redirect(to: ~p"/")}
|> push_navigate(to: ~p"/")}
end
end
end
4 changes: 2 additions & 2 deletions lib/pears_web/components/add_track_form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ defmodule PearsWeb.AddTrackForm do
def handle_event("add_track", %{"track-name" => track_name}, socket) do
case Pears.add_track(socket.assigns.team.name, track_name) do
{:ok, _} ->
{:noreply, push_redirect(socket, to: ~p"/")}
{:noreply, push_navigate(socket, to: ~p"/")}

{:error, _} ->
{:noreply,
socket
|> put_flash(:error, "Sorry, a track with the name '#{track_name}' already exists")
|> push_redirect(to: ~p"/")}
|> push_navigate(to: ~p"/")}
end
end
end
2 changes: 1 addition & 1 deletion lib/pears_web/live/team_login_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ defmodule PearsWeb.TeamLoginLive do

@decorate trace("PearsWeb.TeamLoginLive.mount", include: [:name, :socket])
def mount(_params, _session, socket) do
name = live_flash(socket.assigns.flash, :name)
name = Phoenix.Flash.get(socket.assigns.flash, :name)
form = to_form(%{"name" => name}, as: "team")
{:ok, assign(socket, form: form), temporary_assigns: [form: form]}
end
Expand Down
Loading

0 comments on commit 539ff3b

Please sign in to comment.