- Add Delete method to GameStore and Persister interface - Add delete button to game list on home page - Verify user owns game before allowing deletion - Use status constants instead of magic numbers - Remove unused variable in persister
70 lines
1.6 KiB
Go
70 lines
1.6 KiB
Go
package ui
|
|
|
|
import (
|
|
"github.com/ryanhamamura/via/h"
|
|
)
|
|
|
|
func LobbyView(nicknameBind, createGameKeyDown, createGameClick h.H, isLoggedIn bool, username string, logoutClick h.H, userGames []GameListItem, deleteGameClick func(id string) h.H) h.H {
|
|
var authSection h.H
|
|
if isLoggedIn {
|
|
authSection = AuthHeader(username, logoutClick)
|
|
} else {
|
|
authSection = GuestBanner()
|
|
}
|
|
|
|
return h.Main(h.Class("container"),
|
|
h.Div(h.Class("lobby"),
|
|
authSection,
|
|
h.H1(h.Text("Connect 4")),
|
|
h.P(h.Text("Challenge a friend to a game of Connect 4!")),
|
|
h.Form(
|
|
h.FieldSet(
|
|
h.Label(h.Text("Your Nickname"), h.Attr("for", "nickname")),
|
|
h.Input(
|
|
h.ID("nickname"),
|
|
h.Type("text"),
|
|
h.Placeholder("Enter your nickname"),
|
|
nicknameBind,
|
|
h.Attr("required"),
|
|
createGameKeyDown,
|
|
),
|
|
),
|
|
h.Button(
|
|
h.Type("button"),
|
|
h.Text("Create Game"),
|
|
createGameClick,
|
|
),
|
|
),
|
|
GameList(userGames, deleteGameClick),
|
|
),
|
|
)
|
|
}
|
|
|
|
func NicknamePrompt(nicknameBind, setNicknameKeyDown, setNicknameClick h.H) h.H {
|
|
return h.Main(h.Class("container"),
|
|
h.Div(h.Class("lobby"),
|
|
h.H1(h.Text("Join Game")),
|
|
h.P(h.Text("Enter your nickname to join the game.")),
|
|
h.Form(
|
|
h.FieldSet(
|
|
h.Label(h.Text("Your Nickname"), h.Attr("for", "nickname")),
|
|
h.Input(
|
|
h.ID("nickname"),
|
|
h.Type("text"),
|
|
h.Placeholder("Enter your nickname"),
|
|
nicknameBind,
|
|
h.Attr("required"),
|
|
h.Attr("autofocus"),
|
|
setNicknameKeyDown,
|
|
),
|
|
),
|
|
h.Button(
|
|
h.Type("button"),
|
|
h.Text("Join"),
|
|
setNicknameClick,
|
|
),
|
|
),
|
|
),
|
|
)
|
|
}
|