Commit df277c4e authored by Karen Konou's avatar Karen Konou

[Team] team layout component

parent 08c8d76c
Pipeline #3053 failed with stage
in 0 seconds
......@@ -2,17 +2,20 @@ module Gargantext.Components.Nodes.Team where
import Gargantext.Prelude
import Effect.Class (liftEffect)
import Gargantext.Components.App.Store (Boxes)
import Gargantext.Components.FolderView as FV
import Gargantext.Components.GraphQL.Endpoints (getTeam, deleteTeamMembership)
import Gargantext.Components.GraphQL.Team (TeamMember)
import Gargantext.Components.GraphQL.Endpoints (getTeam)
import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Sessions (Session)
import Gargantext.Types (ID)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Team"
......@@ -39,6 +42,9 @@ teamLayoutMain = R2.leafComponent teamLayoutMainCpt
teamLayoutMainCpt :: R.Component Props
teamLayoutMainCpt = here.component "teamLayoutMain" cpt where
cpt { nodeId, session, boxes } _ = do
reload <- T.useBox T2.newReload
_ <- T.useLive T.unequal reload
useLoader { errorHandler
, loader: loadTeam
, path: { nodeId, session }
......@@ -46,6 +52,7 @@ teamLayoutMainCpt = here.component "teamLayoutMain" cpt where
, team
, nodeId
, session
, reload
}
}
where
......@@ -55,17 +62,22 @@ type TeamProps =
( boxes :: Boxes
, nodeId :: ID
, session :: Session
, team :: Array TeamMember )
, team :: Array TeamMember
, reload :: T.Box T2.Reload )
teamLayoutRows :: R2.Leaf TeamProps
teamLayoutRows = R2.leafComponent teamLayoutRowsCpt
teamLayoutRowsCpt :: R.Component TeamProps
teamLayoutRowsCpt = here.component "teamLayoutRows" cpt where
cpt { team } _ = do
cpt { team, nodeId, session, reload } _ = do
pure $ H.div {} $ map makeTeam team
where
makeTeam { username } = H.p {} [H.text username]
makeTeam { username, shared_folder_id } = H.div {} [H.text username, H.button {className: "btn btn-danger", on: {click: submit shared_folder_id}} [ H.text "remove" ]]
submit sharedFolderId = do
_ <- saveDeleteTeam { session, nodeId, sharedFolderId }
liftEffect $ T2.reload reload
type LoadProps =
(
......@@ -76,3 +88,14 @@ type LoadProps =
loadTeam :: Record LoadProps -> AffRESTError (Array TeamMember)
loadTeam { session, nodeId } = getTeam session nodeId
type DeleteProps =
(
session :: Session,
nodeId :: Int,
sharedFolderId :: Int
)
saveDeleteTeam ∷ Record DeleteProps -> AffRESTError Int
saveDeleteTeam { session, nodeId, sharedFolderId } = deleteTeamMembership session sharedFolderId nodeId
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