From 8cd63a64abafe21378c35c2489d49f24c9ece3c9 Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 4 Apr 2016 01:27:36 +0200 Subject: Add income list CRUD in user page --- src/client/elm/LoggedIn/Home/Account/Model.elm | 60 -------------------------- 1 file changed, 60 deletions(-) delete mode 100644 src/client/elm/LoggedIn/Home/Account/Model.elm (limited to 'src/client/elm/LoggedIn/Home/Account/Model.elm') diff --git a/src/client/elm/LoggedIn/Home/Account/Model.elm b/src/client/elm/LoggedIn/Home/Account/Model.elm deleted file mode 100644 index d04f865..0000000 --- a/src/client/elm/LoggedIn/Home/Account/Model.elm +++ /dev/null @@ -1,60 +0,0 @@ -module LoggedIn.Home.Account.Model - ( Model - , IncomeEdition - , init - , initIncomeEdition - , getCurrentIncome - , validateIncome - ) where - -import Result as Result exposing (Result(..)) -import Dict -import String - -import Utils.Dict exposing (mapValues) - -import Model.Translations exposing (..) -import Model.Income exposing (..) -import Model.User exposing (UserId) - -type alias Model = - { visibleDetail : Bool - , incomeEdition : Maybe IncomeEdition - } - -init : Model -init = - { visibleDetail = False - , incomeEdition = Nothing - } - -getCurrentIncome : Incomes -> UserId -> Model -> Maybe Int -getCurrentIncome incomes me account = - incomes - |> Dict.filter (\_ income -> income.userId == me) - |> Dict.values - |> List.sortBy .creation - |> List.reverse - |> List.head - |> Maybe.map .amount - -type alias IncomeEdition = - { income : String - , error : Maybe String - } - -initIncomeEdition : Int -> IncomeEdition -initIncomeEdition income = - { income = toString income - , error = Nothing - } - -validateIncome : String -> Translations -> Result String Int -validateIncome amount translations = - case String.toInt amount of - Ok number -> - if number > 0 - then Ok number - else Err <| getMessage "IncomeMustBePositiveNumber" translations - Err _ -> - Err <| getMessage "IncomeRequired" translations -- cgit v1.2.3