diff options
author | Joris Guyonvarch | 2015-07-06 00:16:45 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-07-06 00:16:45 +0200 |
commit | 4ce9751c9e645916fdde71874c2cdadd252f32a0 (patch) | |
tree | 1014c58787231cbdc3ae2799f32127b40ab393ab /src/client |
Setting up Scotty, Persistent, Clay, Blaze, Esqueleto, Elm
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/Main.elm | 43 | ||||
-rw-r--r-- | src/client/View/Page.elm | 18 |
2 files changed, 61 insertions, 0 deletions
diff --git a/src/client/Main.elm b/src/client/Main.elm new file mode 100644 index 0000000..dd87b8c --- /dev/null +++ b/src/client/Main.elm @@ -0,0 +1,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 diff --git a/src/client/View/Page.elm b/src/client/View/Page.elm new file mode 100644 index 0000000..47e0c1c --- /dev/null +++ b/src/client/View/Page.elm @@ -0,0 +1,18 @@ +module View.Page + ( renderPage + ) where + +import Html exposing (..) +import Html as H +import Html.Attributes exposing (..) +import Html.Attributes as A +import Html.Events exposing (..) + +renderPage : Html +renderPage = + header + [] + [ h1 + [] + [ text "Payments" ] + ] |