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

parent 8c1bf0e6
...@@ -7,7 +7,7 @@ import Data.Maybe (Maybe(..)) ...@@ -7,7 +7,7 @@ import Data.Maybe (Maybe(..))
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Effect.Console (log) import Effect.Console (log)
import Thermite (PerformAction, modifyState) import Thermite (StateCoTransformer, modifyState)
import Gargantext.Config (toUrl, NodeType(..), End(..)) import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config.REST (get) import Gargantext.Config.REST (get)
...@@ -17,13 +17,11 @@ import Gargantext.Prelude ...@@ -17,13 +17,11 @@ import Gargantext.Prelude
getUser :: Int -> Aff (Either String User) getUser :: Int -> Aff (Either String User)
getUser id = get $ toUrl Back Node id getUser id = get $ toUrl Back Node id
fetchUser :: Int -> StateCoTransformer State Unit
performAction :: PerformAction State {} Action fetchUser userId = do
performAction (FetchUser userId) _ _ = do
value <- lift $ getUser userId value <- lift $ getUser userId
_ <- case value of _ <- case value of
(Right user) -> void $ modifyState $ _user ?~ user (Right user) -> void $ modifyState $ _user ?~ user
(Left err) -> do (Left err) -> do
logs err logs err
logs "Fetching user..." logs "Fetching user..."
performAction _ _ _ = pure unit
...@@ -3,11 +3,16 @@ module Gargantext.Pages.Annuaire.User.Users.Specs ...@@ -3,11 +3,16 @@ module Gargantext.Pages.Annuaire.User.Users.Specs
layoutUser) layoutUser)
where where
import Gargantext.Pages.Annuaire.User.Users.Specs.Renders
import Thermite (Spec, simpleSpec) import Thermite (PerformAction, Spec, simpleSpec)
import Gargantext.Pages.Annuaire.User.Users.Types (Action, State) import Gargantext.Prelude
import Gargantext.Pages.Annuaire.User.Users.API (performAction) 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 :: Spec State {} Action
layoutUser = simpleSpec performAction render 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