blob: 1379323b6b0b13366d660dcb17fcab8a99fd4e8c (
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
|
module Update.LoggedIn.Monthly
( MonthlyAction(..)
, updateMonthly
) where
import Model.Payment exposing (Payment, PaymentId)
import Model.View.LoggedIn.Monthly exposing (..)
type MonthlyAction =
ToggleDetail
| AddPayment Payment
| DeletePayment PaymentId
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 id ->
{ monthly
| payments <- List.filter (\payment -> payment.id /= id) monthly.payments
}
|