aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Update/LoggedIn/Monthly.elm
blob: 3741e1f1eb89a0481112fb4f39d0b44adf84671a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Update.LoggedIn.Monthly
  ( updateMonthly
  ) where

import Model.Action.MonthlyAction exposing (..)
import Model.View.LoggedIn.Monthly exposing (..)

updateMonthly : MonthlyAction -> Monthly -> Monthly
updateMonthly action monthly =
  case action of
    ToggleDetail ->
      { monthly | visibleDetail = not monthly.visibleDetail }
    AddPayment payment ->
      { monthly
      | payments = payment :: monthly.payments
      , visibleDetail = True
      }
    DeletePayment payment ->
      { monthly
      | payments = List.filter (((/=) payment.id) << .id) monthly.payments
      }