diff options
Diffstat (limited to 'frontend/app/Page.hs')
-rw-r--r-- | frontend/app/Page.hs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/frontend/app/Page.hs b/frontend/app/Page.hs index 84a551f..762ae90 100644 --- a/frontend/app/Page.hs +++ b/frontend/app/Page.hs @@ -11,6 +11,7 @@ import Data.Bifunctor import Data.Default import Data.Function import Miso +import Page.EditValue qualified as EditValue import Page.ListCollection qualified as ListCollection import Route (Route) import Route qualified as Route @@ -18,26 +19,35 @@ import Route qualified as Route data Page = Home | ListCollection ListCollection.Model + | EditValue EditValue.Model deriving (Show, Eq) -instance Default Page where - def = Home - data Action = HandleListCollection ListCollection.Action + | HandleEditValue EditValue.Action deriving (Show, Eq) +instance Default Page where + def = Home + initialPage :: Route -> JSM (Either String Page) initialPage Route.Home = pure (Right Home) initialPage (Route.ListCollection c) = fmap ListCollection <$> ListCollection.initialModel c +initialPage (Route.EditValue c f) = + fmap EditValue <$> EditValue.initialModel c f updatePage :: Action -> Page -> Effect Action Page updatePage (HandleListCollection action) (ListCollection m) = ListCollection.updateModel action m & bimap HandleListCollection ListCollection updatePage (HandleListCollection _) p = noEff p +updatePage (HandleEditValue action) (EditValue m) = + EditValue.updateModel action m + & bimap HandleEditValue EditValue +updatePage (HandleEditValue _) p = noEff p viewPage :: Page -> View Action viewPage Home = text "home" viewPage (ListCollection m) = HandleListCollection <$> ListCollection.viewModel m +viewPage (EditValue m) = HandleEditValue <$> EditValue.viewModel m |