module Advance exposing (Advance
, Msg
, view
, update
, init)
import Debug
import Json.Decode as Decode
import Validated exposing (Validated(..))
import Html exposing (Html, div, input, p, label, text, a)
import Html.Attributes exposing (type', class)
import Http
type alias Advance =
{ amount : Validated Int String
, split : Validated Int String
}
type Msg = SetAmount Int
| SetSplit Int
| Submit
| SubmitFail Http.Error
| SubmitSucceed (Decode.Decoder String)
init : Advance
init = { amount = Clean
, split = Clean
}
update : Msg -> Advance -> (Advance, Cmd Msg)
update msg model =
case msg of
SetAmount amount -> model ! []
SetSplit split -> model ! []
Submit -> model ! []
SubmitFail error ->
Debug.log (toString error) (model ! [])
SubmitSucceed response ->
Debug.log "success" (model ! [])
validate : Advance -> Result Advance Advance
validate advance =
Ok advance
view : Advance -> Html Msg
view model =
div []
[ label [ class "label" ] [ text "Amount" ]
, p [ class "control" ] [ input [ type' "range" ] [] ]
, label [ class "label" ] [ text "Split" ]
, p [ class "control" ] [ input [ type' "range" ] [] ]
, p [ class "control" ]
[ a [ class "button is-primary" ] [ text "Submit" ] ]
]