I’m trying to modify the SAFE bookstore as described in the README, but I can’t get the “/tomato” page to display any text.
When following the README instructions, I get warnings, but even with the changes below (ie without warning), no text is displayed.
Any idea what is wrong?
Thanks
diff --git a/src/Client/App.fs b/src/Client/App.fs
index 16e6ae7..a6f132e 100644
--- a/src/Client/App.fs
+++ b/src/Client/App.fs
@@ -37,6 +37,8 @@ handleNotFound model
| Some Page.Home ->
{ model with PageModel = HomePageModel }, Cmd.none
+ | Some Page.Tomato ->
+ { model with PageModel = TomatoModel}, Cmd.none
let loadUser () : UserData option =
let userDecoder = Decode.Auto.generateDecoder<UserData>()
@@ -54,7 +56,8 @@ handleNotFound model
| Some Page.Home, HomePageModel -> model, Cmd.none
| Some Page.Login, LoginModel _ -> model, Cmd.none
| Some Page.WishList, WishListModel _ -> model, Cmd.none
- | _, HomePageModel | _, LoginModel _ | _, WishListModel _ ->
+ | Some Page.Tomato, TomatoModel -> model, Cmd.none
+ | _, HomePageModel | _, LoginModel _ | _, WishListModel _ | _, TomatoModel ->
// unknown page or page does not match model -> go to home page
{ User = None; PageModel = HomePageModel }, Cmd.none
diff --git a/src/Client/Pages.fs b/src/Client/Pages.fs
index c91b98f..3c170e9 100644
--- a/src/Client/Pages.fs
+++ b/src/Client/Pages.fs
@@ -8,12 +8,14 @@ open Elmish.Browser.UrlParser
| Home
| Login
| WishList
+ | Tomato
let toPath =
function
| Page.Home -> "/"
| Page.Login -> "/login"
| Page.WishList -> "/wishlist"
+ | Page.Tomato -> "/tomato"
/// The URL is turned into a Result.
@@ -21,6 +23,8 @@ open Elmish.Browser.UrlParser
oneOf
[ map Page.Home (s "")
map Page.Login (s "login")
- map Page.WishList (s "wishlist") ]
+ map Page.WishList (s "wishlist")
+ map Page.Tomato (s "tomato")]
+
let urlParser location = parsePath pageParser location
diff --git a/src/Client/Shared.fs b/src/Client/Shared.fs
index 0a04920..39dca37 100644
--- a/src/Client/Shared.fs
+++ b/src/Client/Shared.fs
@@ -6,6 +6,7 @@ open ServerCode.Domain
| HomePageModel
| LoginModel of Login.Model
| WishListModel of WishList.Model
+ | TomatoModel
// DEMO03 - The complete app state
type Model = {
@@ -43,5 +44,6 @@ yield Home.view ()
yield Login.view m (LoginMsg >> dispatch)
| WishListModel m ->
yield WishList.view m (WishListMsg >> dispatch)
+ | TomatoModel -> yield h4 [] [ str "Tomatoes taste good!"]
]
]