aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Update/LoggedIn/AddPayment.elm
blob: 62eda855bfe438a4a004afb8ca4e6542abcbd942 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Update.LoggedIn.AddPayment
  ( updateAddPayment
  ) where

import Model.Action.AddPaymentAction exposing (..)
import Model.View.LoggedIn.AddPayment exposing (..)

updateAddPayment : AddPaymentAction -> AddPayment -> AddPayment
updateAddPayment action addPayment =
  case action of
    UpdateName name ->
      { addPayment | name = name }
    UpdateCost cost ->
      { addPayment | cost = cost }
    AddError nameError costError ->
      { addPayment
      | nameError = nameError
      , costError = costError
      }
    ToggleFrequency ->
      { addPayment
      | frequency = if addPayment.frequency == Punctual then Monthly else Punctual
      }