Skip to content

Commit

Permalink
Limit when we show the create chat button
Browse files Browse the repository at this point in the history
* Only show if the championship is in the future
* Only show for in season drafts
  • Loading branch information
axelclark committed Apr 11, 2024
1 parent b5c573c commit 8f28c11
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/ex338_web/live/championship_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ defmodule Ex338Web.ChampionshipLive.Show do
</button>
</div>
<% end %>
<%= if show_create_chat(@current_user, @chat) do %>
<%= if show_create_chat(@current_user, @championship, @chat) do %>
<div class="flex-shrink-0 mt-2 ml-4">
<button
id="create-chat-button"
Expand Down Expand Up @@ -839,11 +839,12 @@ defmodule Ex338Web.ChampionshipLive.Show do
"-"
end

defp show_create_chat(%{admin: true}, nil) do
true
defp show_create_chat(%{admin: true}, championship, nil) do
championship.in_season_draft and
DateTime.before?(DateTime.utc_now(), championship.championship_at)
end

defp show_create_chat(_user, _chat) do
defp show_create_chat(_user, _championship, _chat) do
false
end

Expand Down

0 comments on commit 8f28c11

Please sign in to comment.