52 lines
1.3 KiB
FSharp
52 lines
1.3 KiB
FSharp
module App.View
|
|
|
|
open Elmish
|
|
open Elmish.Browser.Navigation
|
|
open Fable.Core
|
|
open Fable.Core.JsInterop
|
|
open Fable.Import
|
|
open Fable.Import.Browser
|
|
open Types
|
|
open App.State
|
|
open App.Types
|
|
open Global
|
|
|
|
importAll "../sass/main.scss"
|
|
|
|
open Fable.Helpers.React
|
|
open Fable.Helpers.React.Props
|
|
open Elmish.React.Common
|
|
open ServiceContext
|
|
|
|
|
|
let topLevel (sc:ServiceContext.ServiceContext) currentPage dispatch content =
|
|
div
|
|
[ Class "columns is-fullheight" ]
|
|
[ Nav.navRoot currentPage sc dispatch
|
|
div [ Class "column is-main-content" ]
|
|
[ content ]
|
|
]
|
|
|
|
let root model dispatch =
|
|
match model with
|
|
| PreLogin m -> Login.root m (LoginMsg >> dispatch)
|
|
| LoggedIn model ->
|
|
match model.page with
|
|
| UsersModel m -> Users.View.root m (UsersMsg>>dispatch) |> topLevel model.context model.page dispatch
|
|
| AccountsModel m -> Accounts.View.root m (AccountsMsg>>dispatch) |> topLevel model.context model.page dispatch
|
|
| ReportsModel m -> Reports.View.root m (ReportsMsg>>dispatch) |> topLevel model.context model.page dispatch
|
|
|
|
open Elmish.React
|
|
open Elmish.Debug
|
|
open Elmish.HMR
|
|
|
|
// App
|
|
Program.mkProgram init update root
|
|
#if DEBUG
|
|
//|> Program.withConsoleTrace
|
|
//|> Program.withDebugger
|
|
//|> Program.withHMR
|
|
#endif
|
|
|> Program.withReactUnoptimized "elmish-app"
|
|
|> Program.run
|