mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 03:32:06 +00:00
show date, hide puzzle search for non premium
This commit is contained in:
@@ -88,7 +88,8 @@ defmodule ChesstrainerWeb.LandingComponents do
|
||||
turn: turn_label(endgame),
|
||||
title: title(endgame),
|
||||
themes: theme_names(endgame),
|
||||
orientation: orientation(endgame)
|
||||
orientation: orientation(endgame),
|
||||
date: Calendar.strftime(assigns.date || Date.utc_today(), "%d %b %Y")
|
||||
)
|
||||
|
||||
~H"""
|
||||
@@ -101,6 +102,7 @@ defmodule ChesstrainerWeb.LandingComponents do
|
||||
<strong>{@turn}</strong>
|
||||
</span>
|
||||
</div>
|
||||
<div>{@date}</div>
|
||||
</div>
|
||||
|
||||
<.board_grid fen={@fen} orientation={@orientation} />
|
||||
|
||||
@@ -109,9 +109,14 @@ defmodule ChesstrainerWeb.Layouts do
|
||||
end
|
||||
|
||||
defp nav_links(scope) do
|
||||
marketing = [
|
||||
%{label: "Puzzle Search", href: "/endgames"}
|
||||
]
|
||||
marketing =
|
||||
if premium?(scope) do
|
||||
[
|
||||
%{label: "Puzzle Search", href: "/endgames"}
|
||||
]
|
||||
else
|
||||
[]
|
||||
end
|
||||
|
||||
admin =
|
||||
if admin?(scope) do
|
||||
@@ -142,6 +147,8 @@ defmodule ChesstrainerWeb.Layouts do
|
||||
defp admin?(%{user: %{role: role}}), do: Role.admin?(role)
|
||||
defp admin?(_scope), do: false
|
||||
|
||||
defp premium?(scope), do: match?(%{user: %{plan: :premium}}, scope)
|
||||
|
||||
# Signed-in users start a puzzle session; visitors browse the public list.
|
||||
defp start_href(%{user: %{}}), do: ~p"/train"
|
||||
defp start_href(_scope), do: ~p"/endgames"
|
||||
|
||||
Reference in New Issue
Block a user