aboutsummaryrefslogtreecommitdiff
path: root/src/client/Model/Payment.elm
diff options
context:
space:
mode:
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