Commit 285cfdb3 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[DESIGN] User Page info.

parent 92549bc7
...@@ -7,75 +7,64 @@ import Data.Maybe (Maybe(..)) ...@@ -7,75 +7,64 @@ import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Prelude (($), (<<<)) import Prelude (($), (<<<))
import React (ReactElement) import React (ReactElement)
import React.DOM (button, div, h4, li, span, text, ul) import React.DOM (button, div, h4, h3, li, span, text, ul, img)
import React.DOM.Props (_id, className) import React.DOM.Props (_id, className, src)
import React.DOM.Props as RP import React.DOM.Props as RP
import Thermite (Render) import Thermite (Render)
infoRender :: forall props. Tuple String String -> Array ReactElement render :: forall props. Render State props Action
infoRender (Tuple title content) = render dispatch _ state _ =
[ [ button [RP.onClick \_ -> dispatch $ FetchUser 452145] [ text "Fetch User"],
span [className "font-weight-bold text-primary"] [text title], div [className "col-md-12"]
span [className "pull-right"] [text content] $ case state.user of
(Just (User user)) -> display user.name [userInfos user.hyperdata]
Nothing -> display "No user" []
] ]
listElement :: forall props. Array ReactElement -> ReactElement display :: forall props. String -> Array ReactElement -> Array ReactElement
listElement = li [className "list-group-item justify-content-between"] display title elems =
[ div [className "container-fluid"]
card :: forall props. String -> Array ReactElement -> Array ReactElement [ div [className "row", _id "user-page-header"]
card title elems = [ div [className "col-md-6"] [ h3 [] [text title] ]
[ , div [className "col-md-8"] []
div [className "card"] , div [className "col-md-2"] [ span [] [text ""] ]
[ ]
div [className "card-header text-white bg-primary"] , div [className "row", _id "user-page-info"]
[ [ div [className "col-md-12"]
h4 [] [text title] [ div [className "row"]
], [ div [className "col-md-2"]
div [className "card-body"] [ img [src "/images/Gargantextuel-212x300.jpg"] [] ]
elems , div [className "col-md-1"] []
] , div [className "col-md-8"] elems
]
]
]
]
] ]
userInfos :: HyperData -> ReactElement userInfos :: HyperData -> ReactElement
userInfos (HyperData user) = userInfos (HyperData user) =
ul [className "list-group"] ul [className "list-group"]
[ [
listElement <<< infoRender <<< Tuple "Fonction: " $ checkMaybe user.fonction listElement <<< infoRender <<< Tuple "Fonction: " $ checkMaybe user.fonction
, listElement <<< infoRender <<< Tuple "Entité, service: " $ checkMaybe user.entite , listElement <<< infoRender <<< Tuple "Entité, service: " $ checkMaybe user.entite
, listElement <<< infoRender <<< Tuple "Téléphone: " $ checkMaybe user.atel , listElement <<< infoRender <<< Tuple "Téléphone: " $ checkMaybe user.atel
, listElement <<< infoRender <<< Tuple "Courriel: " $ checkMaybe user.mail , listElement <<< infoRender <<< Tuple "Courriel: " $ checkMaybe user.mail
, listElement <<< infoRender <<< Tuple "Bureau: " $ checkMaybe user.bureau , listElement <<< infoRender <<< Tuple "Bureau: " $ checkMaybe user.bureau
, listElement <<< infoRender <<< Tuple "Appelation: " $ checkMaybe user.fonction , listElement <<< infoRender <<< Tuple "Appelation: " $ checkMaybe user.fonction
, listElement <<< infoRender $ Tuple "Lieu: " $ checkMaybe user.lieu , listElement <<< infoRender $ Tuple "Lieu: " $ checkMaybe user.lieu
] ]
where checkMaybe (Nothing) = "" where
checkMaybe (Just a) = a checkMaybe (Nothing) = ""
checkMaybe (Just a) = a
pbInfos :: ReactElement listElement :: forall props. Array ReactElement -> ReactElement
pbInfos = listElement = li [className "list-group-item justify-content-between"]
ul [className "list-group"]
[
listElement <<< infoRender $ Tuple "" "https://www.imt.fr/en/"
, listElement <<< infoRender $ Tuple "" "https://www.imt.fr/en/"
, listElement <<< infoRender $ Tuple "" "https://www.imt.fr/en/"
]
render :: forall props. Render State props Action infoRender :: forall props. Tuple String String -> Array ReactElement
render dispatch _ state _ = infoRender (Tuple title content) =
[ [ span [] [text title]
div [className "container-fluid"] , span [className "badge badge-default badge-pill"] [text content]
[
div [className "row", _id "user-page-info"]
[
div [className "row"]
[
button [RP.onClick \_ -> dispatch $ FetchUser 452145] [ text "Fetch User"],
div [className "col-md-8"]
$ case state.user of
(Just (User user)) -> card user.name [userInfos user.hyperdata]
Nothing -> card "Aucun utilisateur" []
]
] ]
]
]
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