aboutsummaryrefslogtreecommitdiff
path: root/src/client/Update
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-07-21 23:25:58 +0200
committerJoris Guyonvarch2015-07-21 23:25:58 +0200
commit2a53fe50c62d4b7aec0f422998c743f68aa523c1 (patch)
treead32464c99668b477c4006146ec218c947bc9c8f /src/client/Update
parenta271d6034bc4cc631a64476d25d21c83a701fa39 (diff)
Adding the payment without reloading the page
Diffstat (limited to 'src/client/Update')
-rw-r--r--src/client/Update/Payment.elm20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/client/Update/Payment.elm b/src/client/Update/Payment.elm
index 129ccde..136f0f9 100644
--- a/src/client/Update/Payment.elm
+++ b/src/client/Update/Payment.elm
@@ -3,6 +3,9 @@ module Update.Payment
, updatePayment
) where
+import Date
+
+import Model exposing (Model)
import Model.View.PaymentView exposing (..)
import Model.Payment exposing (..)
@@ -10,9 +13,10 @@ type PaymentAction =
UpdateName String
| UpdateCost String
| UpdatePayments Payments
+ | AddPayment String Int
-updatePayment : PaymentAction -> PaymentView -> PaymentView
-updatePayment action paymentView =
+updatePayment : Model -> PaymentAction -> PaymentView -> PaymentView
+updatePayment model action paymentView =
case action of
UpdateName name ->
{ paymentView | name <- name }
@@ -20,3 +24,15 @@ updatePayment action paymentView =
{ paymentView | cost <- cost }
UpdatePayments payments ->
{ paymentView | payments <- payments }
+ AddPayment name cost ->
+ let payment =
+ { creation = Date.fromTime model.currentTime
+ , name = name
+ , cost = cost
+ , userName = paymentView.userName
+ }
+ in { paymentView
+ | payments <- payment :: paymentView.payments
+ , name <- ""
+ , cost <- ""
+ }