From bea39f31ff13e0cd039d024e2708c1405429abf9 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sun, 23 Aug 2020 12:30:59 +0200 Subject: Show errors on same page --- server/lib/Uplcg/Views.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'server/lib/Uplcg/Views.hs') diff --git a/server/lib/Uplcg/Views.hs b/server/lib/Uplcg/Views.hs index c3ef1cc..b5f733c 100644 --- a/server/lib/Uplcg/Views.hs +++ b/server/lib/Uplcg/Views.hs @@ -34,8 +34,8 @@ template title body = H.docTypeHtml $ do " version " H.toHtml version -rooms :: [RoomView] -> [Deck] -> H.Html -rooms rids decks = template "Untitled PL Card Game" $ +rooms :: [RoomView] -> [Deck] -> Maybe String -> H.Html +rooms rids decks mbError = template "Untitled PL Card Game" $ H.div H.! A.class_ "rooms" $ do H.h1 "Rooms" if null rids @@ -50,14 +50,17 @@ rooms rids decks = template "Untitled PL Card Game" $ H.br H.h1 "Create Room" + case mbError of + Nothing -> mempty + Just err -> H.p H.! A.class_ "error" $ H.toHtml err H.form H.! A.method "POST" H.! A.action "/rooms" $ do - H.label H.! A.for "name" $ "Room name: " + H.label H.! A.for "name" $ "Room identifier (alphanumeric only): " H.input H.! A.type_ "text" H.! A.name "id" H.br H.label H.! A.for "name" $ "Password (optional): " H.input H.! A.type_ "text" H.! A.name "password" H.br - H.label H.! A.for "deck" $ "Cards: " + H.label H.! A.for "deck" $ "Card set to use: " H.select H.! A.name "deck" $ for_ decks $ \deck -> H.option H.! A.value (H.toValue deck) $ H.toHtml deck H.br -- cgit v1.2.3