aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn/Home/Account/View.elm
blob: 63fb9973b389388c40ae090af91dc8c9b15166f0 (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
module LoggedIn.Home.Account.View
  ( view
  ) where

import Html exposing (..)
import Html.Attributes exposing (..)

import LoggedData exposing (LoggedData)

import LoggedIn.Home.Model as HomeModel
import LoggedIn.Home.Model.Payer exposing (..)
import LoggedIn.View.Price exposing (price)

import Model exposing (Model)
import Model.User exposing (getUserName)

view : LoggedData -> HomeModel.Model -> Html
view loggedData homeModel =
  div
    [ class "account" ]
    [ div
        [ class "header" ]
        (List.map (exceedingPayer loggedData homeModel) (getOrderedExceedingPayers loggedData.currentTime loggedData.users loggedData.incomes loggedData.payments))
    ]

exceedingPayer : LoggedData -> HomeModel.Model -> ExceedingPayer -> Html
exceedingPayer loggedData homeModel payer =
  div
    [ class "exceedingPayer" ]
    [ span
        [ class "userName" ]
        [ payer.userId
            |> getUserName loggedData.users
            |> Maybe.withDefault "−"
            |> text
        ]
    , span
        [ class "amount" ]
        [ text ("+ " ++ (price loggedData.conf payer.amount)) ]
    ]