States.purs 1.2 KB
Newer Older
1
module Gargantext.Pages.Layout.States where
2 3 4

import Prelude hiding (div)

5 6
import Data.Lens                                       (Lens', lens)
import Data.Maybe                                      (Maybe(Just))
7
import Effect (Effect)
8
import Gargantext.Components.Login                  as LN
9

10
import Gargantext.Pages.Corpus.Graph     as GE
11
import Gargantext.Router                               (Routes(..))
12 13

type AppState =
14 15 16 17 18 19
  { currentRoute       :: Maybe Routes
  , loginState         :: LN.State
  , showLogin          :: Boolean
  , showCorpus         :: Boolean
  , graphExplorerState :: GE.State
  , showTree           :: Boolean
20 21
  }

22 23 24 25 26 27 28 29 30 31 32
initAppState :: Effect AppState
initAppState = do
  loginState <- LN.initialState
  pure
    { currentRoute   : Just Home
    , loginState
    , showLogin      : false
    , showCorpus     : false
    , graphExplorerState : GE.initialState
    , showTree : false
    }
33

34

35
---------------------------------------------------------
36

37 38 39 40
_loginState :: Lens' AppState LN.State
_loginState = lens (\s -> s.loginState) (\s ss -> s{loginState = ss})

_graphExplorerState :: Lens' AppState GE.State
41
_graphExplorerState = lens (\s -> s.graphExplorerState) (\s ss -> s{graphExplorerState = ss})
42