blob: 567025f6877a3575d701fcd4796006b7c50d182e (
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.LoggedView.Monthly
( MonthlyAction(..)
, updateMonthly
) where
import Model.Payment exposing (Payment, PaymentId)
import Model.View.Payment.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
}
|