module Update.Payment.Add
  ( AddPaymentAction(..)
  , updateAddPayment
  ) where

import Model.View.Payment.Add exposing (AddPayment)

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

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
      }