mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
show error page puzzle link only for premium users
This commit is contained in:
@@ -9,6 +9,7 @@ defmodule ChesstrainerWeb.EndgameLive.Train do
|
||||
|
||||
use ChesstrainerWeb, :live_view
|
||||
|
||||
alias Chesstrainer.Accounts.Scope
|
||||
alias Chesstrainer.Puzzles
|
||||
alias ChesstrainerWeb.EndgameLive.PlayCore
|
||||
alias ChesstrainerWeb.PlayComponents
|
||||
@@ -31,7 +32,7 @@ defmodule ChesstrainerWeb.EndgameLive.Train do
|
||||
<.icon name="hero-x-mark" /> Stop session
|
||||
</.button>
|
||||
<.button
|
||||
:if={premium?(@current_scope)}
|
||||
:if={Scope.premium?(@current_scope)}
|
||||
id="puzzle-search"
|
||||
navigate={~p"/endgames"}
|
||||
>
|
||||
@@ -310,9 +311,6 @@ defmodule ChesstrainerWeb.EndgameLive.Train do
|
||||
%{user | rating: socket.assigns.user_rating || user.rating}
|
||||
end
|
||||
|
||||
defp premium?(%{user: %{plan: :premium}}), do: true
|
||||
defp premium?(_scope), do: false
|
||||
|
||||
defp summarise(session, rating) do
|
||||
%{
|
||||
difficulty: session.difficulty,
|
||||
|
||||
Reference in New Issue
Block a user