aboutsummaryrefslogtreecommitdiff
path: root/src/client/ServerCommunication.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/ServerCommunication.elm')
-rw-r--r--src/client/ServerCommunication.elm17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/client/ServerCommunication.elm b/src/client/ServerCommunication.elm
index 47d8c27..55bf947 100644
--- a/src/client/ServerCommunication.elm
+++ b/src/client/ServerCommunication.elm
@@ -9,6 +9,7 @@ import Task as Task exposing (Task)
import Http
import Json.Decode exposing (..)
import Date
+import Time exposing (Time)
import Model.User exposing (UserId)
import Model.Payment exposing (..)
@@ -25,8 +26,8 @@ type Communication =
| SignIn String
| AddPayment UserId String Int
| AddMonthlyPayment String Int
- | SetIncome Int
- | DeletePayment PaymentId UserId Int Int
+ | SetIncome Time Int
+ | DeletePayment Payment Int
| DeleteMonthlyPayment PaymentId
| UpdatePage Int
| SignOut
@@ -50,8 +51,8 @@ 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)
+ SetIncome _ amount -> Just (simple "post" ("/income?amount=" ++ (toString amount)))
+ DeletePayment payment _ -> Just (deletePaymentRequest payment.id)
DeleteMonthlyPayment paymentId -> Just (deletePaymentRequest paymentId)
UpdatePage page -> Just (updatePageRequest page)
SignOut -> Just (simple "post" "/signOut")
@@ -95,12 +96,12 @@ serverResult communication response =
("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 ->
+ SetIncome currentTime amount ->
+ Task.succeed <| U.UpdateLoggedIn (UL.UpdateAccount (UA.UpdateIncome currentTime amount))
+ DeletePayment payment currentPage ->
Http.send Http.defaultSettings (updatePageRequest currentPage)
|> flip Task.andThen (decodeOkResponse paymentsDecoder (\payments ->
- Task.succeed <| U.UpdateLoggedIn (UL.DeletePayment userId cost payments)
+ Task.succeed <| U.UpdateLoggedIn (UL.DeletePayment payment payments)
))
DeleteMonthlyPayment id ->
Task.succeed <| U.UpdateLoggedIn (UL.UpdateMonthly (UM.DeletePayment id))