[REFACTOR] Annuaire.User.Users, make performAction a local def

parent 8c1bf0e6
......@@ -7,7 +7,7 @@ import Data.Maybe (Maybe(..))
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Console (log)
import Thermite (PerformAction, modifyState)
import Thermite (StateCoTransformer, modifyState)
import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config.REST (get)
......@@ -17,13 +17,11 @@ import Gargantext.Prelude
getUser :: Int -> Aff (Either String User)
getUser id = get $ toUrl Back Node id
performAction :: PerformAction State {} Action
performAction (FetchUser userId) _ _ = do
fetchUser :: Int -> StateCoTransformer State Unit
fetchUser userId = do
value <- lift $ getUser userId
_ <- case value of
(Right user) -> void $ modifyState $ _user ?~ user
(Left err) -> do
logs err
logs "Fetching user..."
performAction _ _ _ = pure unit
......@@ -3,11 +3,16 @@ module Gargantext.Pages.Annuaire.User.Users.Specs
layoutUser)
where
import Gargantext.Pages.Annuaire.User.Users.Specs.Renders
import Thermite (Spec, simpleSpec)
import Gargantext.Pages.Annuaire.User.Users.Types (Action, State)
import Gargantext.Pages.Annuaire.User.Users.API (performAction)
import Thermite (PerformAction, Spec, simpleSpec)
import Gargantext.Prelude
import Gargantext.Pages.Annuaire.User.Users.Types (Action(..), State)
import Gargantext.Pages.Annuaire.User.Users.API (fetchUser)
import Gargantext.Pages.Annuaire.User.Users.Specs.Renders (render)
layoutUser :: Spec State {} Action
layoutUser = simpleSpec performAction render
where
performAction :: PerformAction State {} Action
performAction (FetchUser userId) _ _ = fetchUser userId
performAction (TabA _) _ _ = pure unit
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment