From 2a53fe50c62d4b7aec0f422998c743f68aa523c1 Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Tue, 21 Jul 2015 23:25:58 +0200 Subject: Adding the payment without reloading the page --- src/client/Update/Payment.elm | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/client/Update/Payment.elm') 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 <- "" + } -- cgit v1.2.3