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 }