mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-09-19 11:03:52 +00:00
* create endgame play section * add cache tests * normalise FENs - trim and fuill move to 1 on addition * remove svg on root and allow navbar to exist across all pages * update nav items
39 lines
1.0 KiB
Elixir
39 lines
1.0 KiB
Elixir
defmodule ChesstrainerWeb.EndgameLive.PlayerIndex do
|
|
use ChesstrainerWeb, :live_view
|
|
|
|
alias Chesstrainer.Endgames
|
|
|
|
@impl true
|
|
def render(assigns) do
|
|
~H"""
|
|
<Layouts.app flash={@flash}>
|
|
<.header>
|
|
Endgames
|
|
<:subtitle>Pick an endgame to play.</:subtitle>
|
|
</.header>
|
|
|
|
<.table
|
|
id="player-endgames"
|
|
rows={@streams.endgames}
|
|
>
|
|
<:col :let={{_id, endgame}} label="Key">{endgame.key}</:col>
|
|
<:col :let={{_id, endgame}} label="Color">{endgame.color}</:col>
|
|
<:col :let={{_id, endgame}} label="Result">{endgame.result}</:col>
|
|
<:col :let={{_id, endgame}} label="Rating">{endgame.rating}</:col>
|
|
<:action :let={{_id, endgame}}>
|
|
<.link navigate={~p"/endgames/#{endgame}/play"}>Play</.link>
|
|
</:action>
|
|
</.table>
|
|
</Layouts.app>
|
|
"""
|
|
end
|
|
|
|
@impl true
|
|
def mount(_params, _session, socket) do
|
|
{:ok,
|
|
socket
|
|
|> assign(:page_title, "Endgames")
|
|
|> stream(:endgames, Endgames.list_endgames())}
|
|
end
|
|
end
|