aboutsummaryrefslogtreecommitdiff
path: root/src/client/ServerCommunication.elm
diff options
context:
space:
mode:
authorJoris2015-09-13 14:38:08 +0200
committerJoris2015-09-13 14:38:08 +0200
commit6ca60e32f0cbde913d171cd84ed7009ab4281284 (patch)
tree9d365a0e94cbcbfbc0b4e88d8e6cec7ada75fd28 /src/client/ServerCommunication.elm
parent5babf01323bcb62a9880593165af70732f22751b (diff)
downloadbudget-6ca60e32f0cbde913d171cd84ed7009ab4281284.tar.gz
budget-6ca60e32f0cbde913d171cd84ed7009ab4281284.tar.bz2
budget-6ca60e32f0cbde913d171cd84ed7009ab4281284.zip
Adding UI to modify the income
Diffstat (limited to 'src/client/ServerCommunication.elm')
-rw-r--r--src/client/ServerCommunication.elm9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/client/ServerCommunication.elm b/src/client/ServerCommunication.elm
index 5736f77..47d8c27 100644
--- a/src/client/ServerCommunication.elm
+++ b/src/client/ServerCommunication.elm
@@ -18,12 +18,14 @@ import Update as U
import Update.SignIn exposing (..)
import Update.LoggedIn as UL
import Update.LoggedIn.Monthly as UM
+import Update.LoggedIn.Account as UA
type Communication =
NoCommunication
| SignIn String
| AddPayment UserId String Int
| AddMonthlyPayment String Int
+ | SetIncome Int
| DeletePayment PaymentId UserId Int Int
| DeleteMonthlyPayment PaymentId
| UpdatePage Int
@@ -48,6 +50,7 @@ getRequest communication =
SignIn login -> Just (simple "post" ("/signIn?login=" ++ login))
AddPayment userId name cost -> Just (addPaymentRequest name cost Punctual)
AddMonthlyPayment name cost -> Just (addPaymentRequest name cost Monthly)
+ SetIncome amount -> Just (simple "post" ("/income?amount=" ++ (toString amount)))
DeletePayment paymentId _ _ _ -> Just (deletePaymentRequest paymentId)
DeleteMonthlyPayment paymentId -> Just (deletePaymentRequest paymentId)
UpdatePage page -> Just (updatePageRequest page)
@@ -88,10 +91,12 @@ serverResult communication response =
Task.succeed <| U.UpdateLoggedIn (UL.AddPayment userId name cost payments)
))
AddMonthlyPayment name cost ->
- decodeOkResponse
+ decodeResponse
("id" := paymentIdDecoder)
(\id -> Task.succeed <| U.UpdateLoggedIn (UL.AddMonthlyPayment id name cost))
response
+ SetIncome amount ->
+ Task.succeed <| U.UpdateLoggedIn (UL.UpdateAccount (UA.UpdateIncome amount))
DeletePayment id userId cost currentPage ->
Http.send Http.defaultSettings (updatePageRequest currentPage)
|> flip Task.andThen (decodeOkResponse paymentsDecoder (\payments ->
@@ -100,7 +105,7 @@ serverResult communication response =
DeleteMonthlyPayment id ->
Task.succeed <| U.UpdateLoggedIn (UL.UpdateMonthly (UM.DeletePayment id))
UpdatePage page ->
- decodeOkResponse
+ decodeResponse
paymentsDecoder
(\payments -> Task.succeed <| U.UpdateLoggedIn (UL.UpdatePage page payments))
response