diff options
Diffstat (limited to 'src/client/Update')
-rw-r--r-- | src/client/Update/Payment.elm | 20 |
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 <- "" + } |