Actually display the error message
authorTheSaminator <thesaminator@users.noreply.github.com>
Wed, 6 Jul 2022 17:07:40 +0000 (13:07 -0400)
committerTheSaminator <thesaminator@users.noreply.github.com>
Wed, 6 Jul 2022 17:07:40 +0000 (13:07 -0400)
src/jvmMain/kotlin/net/starshipfights/campaign/endpoints_campaign.kt
src/jvmMain/kotlin/net/starshipfights/labs/endpoints_labs.kt

index 58f7a9a8bd44464604779ef59c145d9eeeb7612a..956245c8b30ff43115f48fa25c17f3363ea1656c 100644 (file)
@@ -16,11 +16,17 @@ import net.starshipfights.labs.labUrl
 import net.starshipfights.redirect
 
 fun Routing.installCampaign() {
-       lab("cluster", "Star Clusters") {
+       lab("cluster", "Star Clusters") { errorMessage ->
                section {
                        h1 { +"Star Clusters" }
                        p { +"This is only a test and may not be indicative of the finished star-cluster feature for Starship Fights" }
                        form(action = "/labs/cluster", method = FormMethod.post) {
+                               errorMessage?.let { errorMsg ->
+                                       p {
+                                               style = "color:#d22"
+                                               +errorMsg
+                                       }
+                               }
                                h2 { +"Generation Parameters" }
                                h3 { +"Background Color" }
                                for (color in StarClusterBackground.values()) {
index c19cf2c4a3aae79018a7c4accc298b31ba506003..bd8a95a29e54578d9e57ac500bee4919375211c6 100644 (file)
@@ -18,7 +18,7 @@ private val labsSidebar: Sidebar
 
 fun labUrl(slug: String) = "/labs/$slug"
 
-fun Routing.lab(slug: String, title: String, pageBody: SECTIONS.() -> Unit) {
+fun Routing.lab(slug: String, title: String, pageBody: SECTIONS.(errorMessage: String?) -> Unit) {
        labs[slug] = title
        
        get(labUrl(slug)) {
@@ -27,8 +27,7 @@ fun Routing.lab(slug: String, title: String, pageBody: SECTIONS.() -> Unit) {
                                title,
                                call.standardNavBar(),
                                labsSidebar,
-                               pageBody
-                       )
+                       ) { pageBody(call.request.queryParameters["error"]) }
                )
        }
 }