From 97116a39f10ec0667b6a582e460600b2bcf992c1 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Wed, 8 Sep 2021 08:57:14 +0200 Subject: Remove usages of deprecated route extensions --- .../luxons/sevenwonders/ui/components/Application.kt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/Application.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/Application.kt index 9850f8c0..385abb18 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/Application.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/Application.kt @@ -9,13 +9,26 @@ import org.luxons.sevenwonders.ui.router.Route import react.RBuilder import react.router.dom.* -fun RBuilder.application() = hashRouter { +fun RBuilder.application() = HashRouter { errorDialog() - switch { + Switch { route(Route.GAME_BROWSER.path) { gameBrowser() } route(Route.GAME.path) { gameScene() } route(Route.LOBBY.path) { lobby() } route(Route.HOME.path, exact = true) { home() } - redirect(from = "*", to = "/") + Redirect { + attrs { + from = "*" + to = "/" + } + } + } +} + +private fun RBuilder.route(path: String, exact: Boolean = false, render: RBuilder.() -> Unit) { + Route { + attrs.path = arrayOf(path) + attrs.exact = exact + render() } } -- cgit