From a7db22556b91bc7c499e010b4c051f4442ad8ce2 Mon Sep 17 00:00:00 2001 From: Joris Date: Tue, 29 Dec 2015 22:38:42 +0100 Subject: Using persona to validate emails --- src/client/Model/View/LoggedIn/Account.elm | 67 ------------------------------ 1 file changed, 67 deletions(-) delete mode 100644 src/client/Model/View/LoggedIn/Account.elm (limited to 'src/client/Model/View/LoggedIn/Account.elm') diff --git a/src/client/Model/View/LoggedIn/Account.elm b/src/client/Model/View/LoggedIn/Account.elm deleted file mode 100644 index 2bb3ae7..0000000 --- a/src/client/Model/View/LoggedIn/Account.elm +++ /dev/null @@ -1,67 +0,0 @@ -module Model.View.LoggedIn.Account - ( Account - , IncomeEdition - , initAccount - , initIncomeEdition - , getCurrentIncome - , validateIncome - ) where - -import Result as Result exposing (Result(..)) -import Dict - -import Utils.Validation exposing (..) -import Utils.Dict exposing (mapValues) - -import Model.Translations exposing (..) -import Model.Payer exposing (..) -import Model.User exposing (UserId) - -type alias Account = - { me : UserId - , payers : Payers - , visibleDetail : Bool - , incomeEdition : Maybe IncomeEdition - } - -initAccount : UserId -> Payers -> Account -initAccount me payers = - { me = me - , payers = - payers - |> mapValues - (\payer -> - { payer | incomes <- List.sortBy .creation payer.incomes } - ) - , visibleDetail = False - , incomeEdition = Nothing - } - -getCurrentIncome : Account -> Maybe Int -getCurrentIncome account = - case Dict.get account.me account.payers of - Just payer -> - payer.incomes - |> List.sortBy .creation - |> List.reverse - |> List.head - |> Maybe.map .amount - Nothing -> - Nothing - -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 = - amount - |> validateNonEmpty (getMessage "IncomeRequired" translations) - |> flip Result.andThen (validateNumber (getMessage "IncomeMustBePositiveNumber" translations) (\number -> number > 0)) -- cgit v1.2.3