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 719a563..5ddcfb9 100644
--- a/src/client/ServerCommunication.elm
+++ b/src/client/ServerCommunication.elm
@@ -11,6 +11,7 @@ import Json.Decode exposing (..)
import Date
import Model.Message exposing (messageDecoder)
+import Model.User exposing (UserId)
import Model.Payment exposing (PaymentId, perPage, paymentsDecoder)
import Update as U
@@ -20,8 +21,8 @@ import Update.Payment as UP
type Communication =
NoCommunication
| SignIn String
- | AddPayment String String Int
- | DeletePayment PaymentId String Int Int
+ | AddPayment UserId String Int
+ | DeletePayment PaymentId UserId Int Int
| UpdatePage Int
| SignOut
@@ -43,10 +44,10 @@ getRequest communication =
Nothing
SignIn login ->
Just (simple "post" ("/signIn?login=" ++ login))
- AddPayment userName paymentName cost ->
+ AddPayment userId paymentName cost ->
Just (simple "post" ("/payment/add?name=" ++ paymentName ++ "&cost=" ++ (toString cost)))
DeletePayment paymentId _ _ _ ->
- Just (simple "post" ("payment/delete?id=" ++ paymentId))
+ Just (simple "post" ("payment/delete?id=" ++ (toString paymentId)))
UpdatePage page ->
Just (updatePageRequest page)
SignOut ->
@@ -73,7 +74,7 @@ serverResult communication response =
Task.succeed U.NoOp
SignIn login ->
Task.succeed (U.UpdateSignIn (ValidLogin login))
- AddPayment userName paymentName cost ->
+ AddPayment userId paymentName cost ->
Http.send Http.defaultSettings (updatePageRequest 1)
|> Task.map (\response ->
if response.status == 200
@@ -81,11 +82,11 @@ serverResult communication response =
decodeResponse
response
paymentsDecoder
- (\payments -> U.UpdatePayment (UP.AddPayment userName cost payments))
+ (\payments -> U.UpdatePayment (UP.AddPayment userId cost payments))
else
U.NoOp
)
- DeletePayment id userName cost currentPage ->
+ DeletePayment id userId cost currentPage ->
Http.send Http.defaultSettings (updatePageRequest currentPage)
|> Task.map (\response ->
if response.status == 200
@@ -93,7 +94,7 @@ serverResult communication response =
decodeResponse
response
paymentsDecoder
- (\payments -> U.UpdatePayment (UP.Remove userName cost payments))
+ (\payments -> U.UpdatePayment (UP.Remove userId cost payments))
else
U.NoOp
)