aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Update/LoggedIn/Add.elm
blob: 92bdb7e2bc2ee690116ca8e2fc09da0f8fca226c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module Update.LoggedIn.Add
  ( AddPaymentAction(..)
  , updateAddPayment
  ) where

import Model.View.LoggedIn.Add exposing (..)

type AddPaymentAction =
  UpdateName String
  | UpdateCost String
  | AddError (Maybe String) (Maybe String)
  | ToggleFrequency

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
      }