Commit 5529935a authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] Contact Page (WIP)

parent 9ca4f84b
...@@ -13,7 +13,8 @@ import Gargantext.Components.GraphExplorer (explorerLayout) ...@@ -13,7 +13,8 @@ import Gargantext.Components.GraphExplorer (explorerLayout)
import Gargantext.Components.Lang (LandingLang(..)) import Gargantext.Components.Lang (LandingLang(..))
import Gargantext.Components.Login (login) import Gargantext.Components.Login (login)
import Gargantext.Components.Nodes.Annuaire (annuaireLayout) import Gargantext.Components.Nodes.Annuaire (annuaireLayout)
import Gargantext.Components.Nodes.Annuaire.User.Contacts (annuaireUserLayout, userLayout) import Gargantext.Components.Nodes.Annuaire.User (userLayout)
import Gargantext.Components.Nodes.Annuaire.User.Contact (contactLayout)
import Gargantext.Components.Nodes.Corpus (corpusLayout) import Gargantext.Components.Nodes.Corpus (corpusLayout)
import Gargantext.Components.Nodes.Corpus.Dashboard (dashboardLayout) import Gargantext.Components.Nodes.Corpus.Dashboard (dashboardLayout)
import Gargantext.Components.Nodes.Corpus.Document (documentMainLayout) import Gargantext.Components.Nodes.Corpus.Document (documentMainLayout)
...@@ -101,17 +102,6 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -101,17 +102,6 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
Annuaire sid nodeId -> withSession sid $ \session -> forested [ Annuaire sid nodeId -> withSession sid $ \session -> forested [
annuaireLayout { frontends, nodeId, session } annuaireLayout { frontends, nodeId, session }
] ]
ContactPage sid aId nodeId -> withSession sid $ \session -> forested [
annuaireUserLayout {
annuaireId: aId
, appReload
, asyncTasksRef
, frontends
, nodeId
, session
, treeReloadRef
}
]
Corpus sid nodeId -> withSession sid $ \session -> forested [ Corpus sid nodeId -> withSession sid $ \session -> forested [
corpusLayout { nodeId, session } corpusLayout { nodeId, session }
] ]
...@@ -204,6 +194,8 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -204,6 +194,8 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
, sessionUpdate , sessionUpdate
} }
} [] } []
----------------------------------------------------------------------------------------
-- | TODO refact UserPage and ContactPage
UserPage sid nodeId -> withSession sid $ \session -> forested [ UserPage sid nodeId -> withSession sid $ \session -> forested [
userLayout { userLayout {
appReload appReload
...@@ -214,3 +206,17 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -214,3 +206,17 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
, treeReloadRef , treeReloadRef
} }
] ]
ContactPage sid aId nodeId -> withSession sid $ \session -> forested [
contactLayout {
annuaireId: aId
, appReload
, asyncTasksRef
, frontends
, nodeId
, session
, treeReloadRef
}
]
...@@ -15,7 +15,7 @@ import Gargantext.Components.DocsTable as DT ...@@ -15,7 +15,7 @@ import Gargantext.Components.DocsTable as DT
import Gargantext.Components.NgramsTable as NT import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.NgramsTable.Core as NTC import Gargantext.Components.NgramsTable.Core as NTC
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData) import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData')
import Gargantext.Components.Nodes.Lists.Types as LTypes import Gargantext.Components.Nodes.Lists.Types as LTypes
import Gargantext.Components.Nodes.Texts.Types as TTypes import Gargantext.Components.Nodes.Texts.Types as TTypes
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
...@@ -52,7 +52,7 @@ type TabsProps = ( ...@@ -52,7 +52,7 @@ type TabsProps = (
appReload :: GUR.ReloadS appReload :: GUR.ReloadS
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor) , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State LTypes.CacheState , cacheState :: R.State LTypes.CacheState
, contactData :: ContactData , contactData :: ContactData'
, frontends :: Frontends , frontends :: Frontends
, nodeId :: Int , nodeId :: Int
, session :: Session , session :: Session
......
...@@ -43,6 +43,40 @@ instance decodeNodeContact :: DecodeJson NodeContact where ...@@ -43,6 +43,40 @@ instance decodeNodeContact :: DecodeJson NodeContact where
derive instance newtypeNodeContact :: Newtype NodeContact _ derive instance newtypeNodeContact :: Newtype NodeContact _
----------------------------------------------------------------------------
newtype Contact' =
Contact'
{ id :: Int
, date :: Maybe String
, hyperdata :: HyperdataContact
, name :: Maybe String
, parentId :: Maybe Int
, typename :: Maybe Int
, userId :: Maybe Int
}
instance decodeContact' :: DecodeJson Contact' where
decodeJson json = do
obj <- decodeJson json
date <- obj .?| "date"
hyperdata <- obj .: "hyperdata"
id <- obj .: "id"
name <- obj .:! "name"
parentId <- obj .?| "parentId"
typename <- obj .?| "typename"
userId <- obj .:! "userId"
pure $ Contact' { id
, date
, hyperdata
, name
, parentId
, typename
, userId
}
newtype Contact = newtype Contact =
...@@ -57,8 +91,7 @@ newtype Contact = ...@@ -57,8 +91,7 @@ newtype Contact =
} }
instance decodeContact :: DecodeJson Contact where
instance decodeUser :: DecodeJson Contact where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
date <- obj .?| "date" date <- obj .?| "date"
...@@ -78,7 +111,40 @@ instance decodeUser :: DecodeJson Contact where ...@@ -78,7 +111,40 @@ instance decodeUser :: DecodeJson Contact where
, userId , userId
} }
derive instance newtypeContact :: Newtype Contact _
----------------------------------------------------------------------------
newtype User =
User
{ id :: Int
, date :: Maybe String
, hyperdata :: HyperdataUser
, name :: Maybe String
, parentId :: Maybe Int
, typename :: Maybe Int
, userId :: Maybe Int
}
instance decodeUser :: DecodeJson User where
decodeJson json = do
obj <- decodeJson json
date <- obj .?| "date"
hyperdata <- obj .: "hyperdata"
id <- obj .: "id"
name <- obj .:! "name"
parentId <- obj .?| "parentId"
typename <- obj .?| "typename"
userId <- obj .:! "userId"
pure $ User { id
, date
, hyperdata
, name
, parentId
, typename
, userId
}
newtype ContactWho = newtype ContactWho =
ContactWho ContactWho
...@@ -321,6 +387,7 @@ defaultHyperdataUser = ...@@ -321,6 +387,7 @@ defaultHyperdataUser =
-- pure $ HyperData {common, shared, specific} -- pure $ HyperData {common, shared, specific}
type ContactData = {contactNode :: Contact, defaultListId :: Int} type ContactData = {contactNode :: Contact, defaultListId :: Int}
type ContactData' = {contactNode :: Contact', defaultListId :: Int}
_shared :: Lens' HyperdataUser HyperdataContact _shared :: Lens' HyperdataUser HyperdataContact
_shared = lens getter setter _shared = lens getter setter
......
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