aboutsummaryrefslogtreecommitdiff
path: root/src/client/Model
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/Model')
-rw-r--r--src/client/Model/Payment.elm10
-rw-r--r--src/client/Model/View/Payment/Edition.elm4
2 files changed, 11 insertions, 3 deletions
diff --git a/src/client/Model/Payment.elm b/src/client/Model/Payment.elm
index ff8f157..fa59943 100644
--- a/src/client/Model/Payment.elm
+++ b/src/client/Model/Payment.elm
@@ -1,6 +1,7 @@
module Model.Payment
( Payments
, Payment
+ , PaymentId
, paymentsDecoder
) where
@@ -10,24 +11,29 @@ import Json.Decode as Json exposing ((:=))
type alias Payments = List Payment
type alias Payment =
- { id : String
+ { id : PaymentId
, creation : Date
, name : String
, cost : Int
, userName : String
}
+type alias PaymentId = String
+
paymentsDecoder : Json.Decoder Payments
paymentsDecoder = Json.list paymentDecoder
paymentDecoder : Json.Decoder Payment
paymentDecoder =
Json.object5 Payment
- ("id" := Json.string)
+ ("id" := paymentIdDecoder)
("creation" := dateDecoder)
("name" := Json.string)
("cost" := Json.int)
("userName" := Json.string)
+paymentIdDecoder : Json.Decoder PaymentId
+paymentIdDecoder = Json.string
+
dateDecoder : Json.Decoder Date
dateDecoder = Json.customDecoder Json.string Date.fromString
diff --git a/src/client/Model/View/Payment/Edition.elm b/src/client/Model/View/Payment/Edition.elm
index a650fa8..f58ce43 100644
--- a/src/client/Model/View/Payment/Edition.elm
+++ b/src/client/Model/View/Payment/Edition.elm
@@ -2,4 +2,6 @@ module Model.View.Payment.Edition
( Edition
) where
-type alias Edition = String
+import Model.Payment exposing (PaymentId)
+
+type alias Edition = PaymentId