aboutsummaryrefslogtreecommitdiff
path: root/src/client/View/Payments/Table.elm
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-07-20 21:55:52 +0200
committerJoris Guyonvarch2015-07-20 21:55:52 +0200
commita271d6034bc4cc631a64476d25d21c83a701fa39 (patch)
tree89ffa3df69999c5c9ed3cda9f4e4ec04f7a6ae1d /src/client/View/Payments/Table.elm
parenta40c4825996c90d107901b0d71162f9356f1395a (diff)
downloadbudget-a271d6034bc4cc631a64476d25d21c83a701fa39.tar.gz
budget-a271d6034bc4cc631a64476d25d21c83a701fa39.tar.bz2
budget-a271d6034bc4cc631a64476d25d21c83a701fa39.zip
Add a payment from the UI, it needs polishing however
Diffstat (limited to 'src/client/View/Payments/Table.elm')
-rw-r--r--src/client/View/Payments/Table.elm51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/client/View/Payments/Table.elm b/src/client/View/Payments/Table.elm
new file mode 100644
index 0000000..34dc058
--- /dev/null
+++ b/src/client/View/Payments/Table.elm
@@ -0,0 +1,51 @@
+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.Payment exposing (Payments, Payment)
+
+import View.Icon exposing (renderIcon)
+
+paymentsTable : Payments -> Html
+paymentsTable payments =
+ table
+ []
+ ([ tr
+ []
+ [ th [] [ renderIcon "user" ]
+ , th [] [ renderIcon "shopping-cart" ]
+ , th [] [ renderIcon "euro" ]
+ , th [] [ renderIcon "calendar" ]
+ ]
+ ] ++ (paymentLines payments))
+
+paymentLines : Payments -> List Html
+paymentLines payments =
+ payments
+ |> List.sortBy (Date.toTime << .creation)
+ |> List.reverse
+ |> List.map paymentLine
+
+paymentLine : Payment -> Html
+paymentLine payment =
+ tr
+ []
+ [ td [] [ text payment.userName ]
+ , td [] [ text payment.name ]
+ , 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)))