blob: dd87b8cba536b6730a9b4cd8b0bc46a73aa63895 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
module Main
( main
) where
import Graphics.Element exposing (..)
import Html exposing (Html)
import Http
import Json.Decode as Json exposing ((:=))
import Task exposing (..)
import Date exposing (..)
import View.Page exposing (renderPage)
main : Html
main = renderPage
getPayments : Task Http.Error (List Payment)
getPayments = Http.get paymentsDecoder "/payments"
type alias Payments = List Payment
type alias Payment =
{ creation : Date
, name : String
, cost : Int
, userName : String
}
paymentsDecoder : Json.Decoder Payments
paymentsDecoder = Json.list paymentDecoder
paymentDecoder : Json.Decoder Payment
paymentDecoder =
Json.object4 Payment
("creation" := dateDecoder)
("name" := Json.string)
("cost" := Json.int)
("userName" := Json.string)
dateDecoder : Json.Decoder Date
dateDecoder = Json.customDecoder Json.string Date.fromString
|