From a78a721df5f91ddb3bb9a755aaf6a44e3996d417 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Fri, 5 Nov 2021 08:44:16 +0200 Subject: Add profile page --- src/Pages/Profile.elm | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src/Pages/Profile.elm') 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) -- cgit v1.3