Skip to content

Commit

Permalink
Show team and player in flash
Browse files Browse the repository at this point in the history
  • Loading branch information
axelclark committed Mar 30, 2024
1 parent af9aecf commit e193cc3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/ex338_web/live/championship_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions test/ex338_web/live/championship_live/show_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -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

0 comments on commit e193cc3

Please sign in to comment.