diff options
author | Joris Guyonvarch | 2015-07-10 00:03:42 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-07-10 00:03:42 +0200 |
commit | 0041c546869f0a7fd59a085cc75b481237b6c380 (patch) | |
tree | 4814108670fc1a3e7c5a334e884accd0e9dc5e96 /src/client/View | |
parent | 4ce9751c9e645916fdde71874c2cdadd252f32a0 (diff) |
Fetching payments and showing them in a table
Diffstat (limited to 'src/client/View')
-rw-r--r-- | src/client/View/Page.elm | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/src/client/View/Page.elm b/src/client/View/Page.elm index 47e0c1c..ca8efc9 100644 --- a/src/client/View/Page.elm +++ b/src/client/View/Page.elm @@ -8,11 +8,51 @@ import Html.Attributes exposing (..) import Html.Attributes as A import Html.Events exposing (..) -renderPage : Html -renderPage = +import Date +import Date exposing (Date) + +import String exposing (append) + +import Model exposing (Model) +import Model.Payment exposing (Payments, Payment) + +renderPage : Model -> Html +renderPage model = header [] [ h1 [] [ text "Payments" ] + , table + [] + ([ tr + [] + [ td [] [ text "Utilisateur" ] + , td [] [ text "Nom" ] + , td [] [ text "Prix" ] + , td [] [ text "Date" ] + ] + ] ++ (List.map renderPayment model.payments)) ] + +renderPayments : Payments -> List Html +renderPayments = + List.map renderPayment + << List.reverse + << List.sortBy (Date.toTime << .creation) + +renderPayment : Payment -> Html +renderPayment payment = + tr + [] + [ td [] [ text payment.name ] + , td [] [ text payment.userName ] + , td [] [ text (toString payment.cost) ] + , td [] [ text (renderDate payment.creation) ] + ] + +renderDate : Date -> String +renderDate date = + toString (Date.day date) + |> flip append (" " ++ (toString (Date.month date))) + |> flip append (" " ++ (toString (Date.year date))) |