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.elm22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/client/Model/Payment.elm b/src/client/Model/Payment.elm
index 4ae50de..313c6be 100644
--- a/src/client/Model/Payment.elm
+++ b/src/client/Model/Payment.elm
@@ -3,26 +3,22 @@ module Model.Payment
, Payments
, Payment
, PaymentId
- , PaymentWithId
, paymentsDecoder
- , removePayment
) where
import Date exposing (..)
import Json.Decode as Json exposing ((:=))
-import Dict exposing (..)
import Model.User exposing (UserId, userIdDecoder)
perPage : Int
perPage = 8
-type alias Payments = Dict PaymentId Payment
-
-type alias PaymentWithId = (PaymentId, Payment)
+type alias Payments = List Payment
type alias Payment =
- { creation : Date
+ { id : PaymentId
+ , creation : Date
, name : String
, cost : Int
, userId : UserId
@@ -31,15 +27,12 @@ type alias Payment =
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" := paymentIdDecoder))
+paymentsDecoder = Json.list paymentDecoder
paymentDecoder : Json.Decoder Payment
paymentDecoder =
- Json.object4 Payment
+ Json.object5 Payment
+ ("id" := paymentIdDecoder)
("creation" := dateDecoder)
("name" := Json.string)
("cost" := Json.int)
@@ -50,6 +43,3 @@ paymentIdDecoder = Json.int
dateDecoder : Json.Decoder Date
dateDecoder = Json.customDecoder Json.string Date.fromString
-
-removePayment : Payments -> PaymentId -> Payments
-removePayment payments paymentId = Dict.remove paymentId payments