aboutsummaryrefslogtreecommitdiff
path: root/src/client/Model/Payment.elm
diff options
context:
space:
mode:
authorJoris2015-09-05 13:53:36 +0200
committerJoris2015-09-05 13:53:36 +0200
commit3b738e0d4cc65f314da7389d4542ec826ba0f454 (patch)
treeee99236117ad698974c5a6e40ab170f617cb06f3 /src/client/Model/Payment.elm
parent139d4a103a6a48880e5f12a796033956f223563c (diff)
downloadbudget-3b738e0d4cc65f314da7389d4542ec826ba0f454.tar.gz
budget-3b738e0d4cc65f314da7389d4542ec826ba0f454.tar.bz2
budget-3b738e0d4cc65f314da7389d4542ec826ba0f454.zip
Using UserId instead of UserName to indentify users
Diffstat (limited to 'src/client/Model/Payment.elm')
-rw-r--r--src/client/Model/Payment.elm12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/client/Model/Payment.elm b/src/client/Model/Payment.elm
index 8a51c66..4ae50de 100644
--- a/src/client/Model/Payment.elm
+++ b/src/client/Model/Payment.elm
@@ -12,6 +12,8 @@ import Date exposing (..)
import Json.Decode as Json exposing ((:=))
import Dict exposing (..)
+import Model.User exposing (UserId, userIdDecoder)
+
perPage : Int
perPage = 8
@@ -23,17 +25,17 @@ type alias Payment =
{ creation : Date
, name : String
, cost : Int
- , userName : String
+ , userId : UserId
}
-type alias PaymentId = String
+type alias PaymentId = Int
paymentsDecoder : Json.Decoder Payments
paymentsDecoder = Json.map Dict.fromList (Json.list paymentWithIdDecoder)
paymentWithIdDecoder : Json.Decoder (PaymentId, Payment)
paymentWithIdDecoder =
- paymentDecoder `Json.andThen` (\payment -> Json.map (\id -> (id, payment)) ("id" := Json.string))
+ paymentDecoder `Json.andThen` (\payment -> Json.map (\id -> (id, payment)) ("id" := paymentIdDecoder))
paymentDecoder : Json.Decoder Payment
paymentDecoder =
@@ -41,10 +43,10 @@ paymentDecoder =
("creation" := dateDecoder)
("name" := Json.string)
("cost" := Json.int)
- ("userName" := Json.string)
+ ("userId" := userIdDecoder)
paymentIdDecoder : Json.Decoder PaymentId
-paymentIdDecoder = Json.string
+paymentIdDecoder = Json.int
dateDecoder : Json.Decoder Date
dateDecoder = Json.customDecoder Json.string Date.fromString