diff --git a/lib/ex338_web/live/championship_live/show.ex b/lib/ex338_web/live/championship_live/show.ex index 0334c437..6e9dbdda 100644 --- a/lib/ex338_web/live/championship_live/show.ex +++ b/lib/ex338_web/live/championship_live/show.ex @@ -62,9 +62,18 @@ defmodule Ex338Web.ChampionshipLive.Show do socket.assigns.fantasy_league.id ) + # need the preloaded in season draft pick + in_season_draft_pick = + Enum.find(championship.in_season_draft_picks, &(&1.id == in_season_draft_pick.id)) + + %{ + draft_pick_asset: %{fantasy_team: %{team_name: team_name}}, + drafted_player: %{player_name: player_name} + } = in_season_draft_pick + socket = socket - |> put_flash(:info, "New pick!") + |> put_flash(:info, "#{team_name} selected #{player_name}!") |> push_event("animate", %{id: "draft-pick-#{in_season_draft_pick.id}-player"}) |> assign(:championship, championship) diff --git a/test/ex338_web/live/championship_live/show_test.exs b/test/ex338_web/live/championship_live/show_test.exs index c9270e27..723de1a0 100644 --- a/test/ex338_web/live/championship_live/show_test.exs +++ b/test/ex338_web/live/championship_live/show_test.exs @@ -231,6 +231,7 @@ defmodule Ex338Web.ChampionshipLive.ShowTest do :in_season_draft_pick, draft_pick_asset: pick_asset2, championship: championship, + fantasy_league: league, position: 2 ) @@ -248,6 +249,8 @@ defmodule Ex338Web.ChampionshipLive.ShowTest do }) assert render(view) =~ horse2.player_name + + assert has_element?(view, "div", "#{team_b.team_name} selected #{horse2.player_name}!") end end end