module View.Payments.Table ( paymentsTable ) where import Html exposing (..) import Html.Attributes exposing (..) import Date import Date exposing (Date) import String exposing (append) import Model exposing (Model) import Model.Payment exposing (Payments, Payment) import View.Icon exposing (renderIcon) import View.Date exposing (renderDate) paymentsTable : Model -> Payments -> Html paymentsTable model payments = table [] ([ tr [] [ th [ class "category" ] [ renderIcon "shopping-cart" ] , th [ class "cost" ] [ renderIcon "euro" ] , th [ class "user" ] [ renderIcon "user" ] , th [ class "date" ] [ renderIcon "calendar" ] ] ] ++ (paymentLines model payments)) paymentLines : Model -> Payments -> List Html paymentLines model payments = payments |> List.sortBy (Date.toTime << .creation) |> List.reverse |> List.map (paymentLine model) paymentLine : Model -> Payment -> Html paymentLine model payment = tr [] [ td [] [ text payment.name ] , td [] [ text ((toString payment.cost) ++ " €") ] , td [] [ text payment.userName ] , td [] [ text (renderDate payment.creation model.translations) ] ]