aboutsummaryrefslogtreecommitdiff
path: root/src/client/View/Payments/Table.elm
blob: e5c1a9a37249bbbdc0a3f502c0f8e3b36369ff53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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) ]
    ]