aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn/Account/Model.elm
diff options
context:
space:
mode:
authorJoris2016-03-28 17:51:14 +0200
committerJoris2016-03-28 17:51:14 +0200
commit166cd04e4b28770ede854dafc9ae30eae64102fe (patch)
tree2245a31243a165acc6f7355534da44cfd17e6038 /src/client/elm/LoggedIn/Account/Model.elm
parentb0d80a5458d7ba4546e5f01f5b6398ea6d23f981 (diff)
downloadbudget-166cd04e4b28770ede854dafc9ae30eae64102fe.tar.gz
budget-166cd04e4b28770ede854dafc9ae30eae64102fe.tar.bz2
budget-166cd04e4b28770ede854dafc9ae30eae64102fe.zip
Create an empty but reachable user page
Diffstat (limited to 'src/client/elm/LoggedIn/Account/Model.elm')
-rw-r--r--src/client/elm/LoggedIn/Account/Model.elm64
1 files changed, 0 insertions, 64 deletions
diff --git a/src/client/elm/LoggedIn/Account/Model.elm b/src/client/elm/LoggedIn/Account/Model.elm
deleted file mode 100644
index 2d0c4a3..0000000
--- a/src/client/elm/LoggedIn/Account/Model.elm
+++ /dev/null
@@ -1,64 +0,0 @@
-module LoggedIn.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 =
- { me : UserId
- , incomes : Incomes
- , visibleDetail : Bool
- , incomeEdition : Maybe IncomeEdition
- }
-
-init : UserId -> Incomes -> Model
-init me incomes =
- { me = me
- , incomes = incomes
- , visibleDetail = False
- , incomeEdition = Nothing
- }
-
-getCurrentIncome : Model -> 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