aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Model
diff options
context:
space:
mode:
authorJoris2016-03-27 20:41:59 +0200
committerJoris2016-03-27 20:41:59 +0200
commit7c050fe2d2c3e8f190e019e1613d37b9d8ef22b9 (patch)
tree1465f7367335492cd246b67ab9a02968517d57a5 /src/client/elm/Model
parent702d60cbcdf85216a1b18416f4480afb77384e8a (diff)
Regroup account modules
Diffstat (limited to 'src/client/elm/Model')
-rw-r--r--src/client/elm/Model/Action/AccountAction.elm17
-rw-r--r--src/client/elm/Model/View/LoggedIn/Account.elm64
2 files changed, 0 insertions, 81 deletions
diff --git a/src/client/elm/Model/Action/AccountAction.elm b/src/client/elm/Model/Action/AccountAction.elm
deleted file mode 100644
index 3e156a5..0000000
--- a/src/client/elm/Model/Action/AccountAction.elm
+++ /dev/null
@@ -1,17 +0,0 @@
-module Model.Action.AccountAction
- ( AccountAction(..)
- ) where
-
-import Time exposing (Time)
-
-import Model.User exposing (UserId)
-import Model.Income exposing (IncomeId)
-
-type AccountAction =
- NoOp
- | ToggleDetail
- | ToggleIncomeEdition
- | UpdateIncomeEdition String
- | UpdateEditionError String
- | UpdateIncome Time Int
- | ValidateUpdateIncome IncomeId Time Int
diff --git a/src/client/elm/Model/View/LoggedIn/Account.elm b/src/client/elm/Model/View/LoggedIn/Account.elm
deleted file mode 100644
index ec75397..0000000
--- a/src/client/elm/Model/View/LoggedIn/Account.elm
+++ /dev/null
@@ -1,64 +0,0 @@
-module Model.View.LoggedIn.Account
- ( Account
- , IncomeEdition
- , initAccount
- , 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 Account =
- { me : UserId
- , incomes : Incomes
- , visibleDetail : Bool
- , incomeEdition : Maybe IncomeEdition
- }
-
-initAccount : UserId -> Incomes -> Account
-initAccount me incomes =
- { me = me
- , incomes = incomes
- , visibleDetail = False
- , incomeEdition = Nothing
- }
-
-getCurrentIncome : Account -> Maybe Int
-getCurrentIncome account =
- account.incomes
- |> Dict.filter (\_ income -> income.userId == account.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