diff options
| author | Jan Tuomi <jan.tuomi@valuemotive.com> | 2021-11-05 08:44:16 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan.tuomi@valuemotive.com> | 2021-11-05 08:44:16 +0200 |
| commit | a78a721df5f91ddb3bb9a755aaf6a44e3996d417 (patch) | |
| tree | 0cee7428856c303287bc38d98fa0a91405cbee5f /src/Pages/Profile.elm | |
| parent | 270123cc18ee8acff4b2819f4a609045bd5194f5 (diff) | |
Add profile page
Diffstat (limited to 'src/Pages/Profile.elm')
| -rw-r--r-- | src/Pages/Profile.elm | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/Pages/Profile.elm b/src/Pages/Profile.elm index a564b3e..479c908 100644 --- a/src/Pages/Profile.elm +++ b/src/Pages/Profile.elm @@ -1,9 +1,12 @@ module Pages.Profile exposing (..) +import Components.PostList exposing (postList) import Css exposing (marginBottom, px) import Html.Styled exposing (..) import Html.Styled.Attributes exposing (css) -import Types exposing (Model, Msg, UrlSegmentUserId) +import RemoteData exposing (RemoteData(..)) +import Types exposing (Model, Msg, Post, UrlSegmentUserId) +import Utils exposing (templ) styles = @@ -14,10 +17,33 @@ styles = } +postsContainer : Model -> UrlSegmentUserId -> Html Msg +postsContainer model id = + let + onlyProfilePosts : List Post -> List Post + onlyProfilePosts posts = + List.filter (\p -> p.author.id == id) posts + in + case model.posts of + Initial -> + div [] [] + + Loading -> + div [] [ text "Loading posts..." ] + + Failure _ -> + div [] [] + + Success posts -> + postList model.now (onlyProfilePosts posts) + + body : Model -> UrlSegmentUserId -> Html Msg -body _ id = +body model id = div [ styles.container ] - [ text id ] + [ h2 [] [ "Posts by {0}" |> templ [ id ] |> text ] + , postsContainer model id + ] profileView : UrlSegmentUserId -> Model -> List (Html Msg) |
