module View.Page ( renderPage ) where import Html exposing (..) import Html as H import Html.Attributes exposing (..) import Html.Attributes as A import Html.Events exposing (..) 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 [] [ th [] [ text "Utilisateur" ] , th [] [ text "Nom" ] , th [] [ text "Prix" ] , th [] [ 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)))