From 3b738e0d4cc65f314da7389d4542ec826ba0f454 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 5 Sep 2015 13:53:36 +0200 Subject: Using UserId instead of UserName to indentify users --- src/client/ServerCommunication.elm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/client/ServerCommunication.elm') 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 ) -- cgit v1.2.3