aboutsummaryrefslogtreecommitdiff
path: root/src/client/Model/View
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/Model/View')
-rw-r--r--src/client/Model/View/LoggedIn/Account.elm67
-rw-r--r--src/client/Model/View/LoggedIn/Add.elm43
-rw-r--r--src/client/Model/View/LoggedIn/Edition.elm7
-rw-r--r--src/client/Model/View/LoggedIn/Monthly.elm17
-rw-r--r--src/client/Model/View/LoggedInView.elm35
-rw-r--r--src/client/Model/View/SignInView.elm15
6 files changed, 0 insertions, 184 deletions
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))
diff --git a/src/client/Model/View/LoggedIn/Add.elm b/src/client/Model/View/LoggedIn/Add.elm
deleted file mode 100644
index 5598084..0000000
--- a/src/client/Model/View/LoggedIn/Add.elm
+++ /dev/null
@@ -1,43 +0,0 @@
-module Model.View.LoggedIn.Add
- ( AddPayment
- , Frequency(..)
- , initAddPayment
- , validateName
- , validateCost
- ) where
-
-import Result as Result exposing (Result(..))
-
-import Utils.Validation exposing (..)
-
-import Model.Translations exposing (..)
-
-type alias AddPayment =
- { name : String
- , nameError : Maybe String
- , cost : String
- , costError : Maybe String
- , frequency : Frequency
- }
-
-initAddPayment : Frequency -> AddPayment
-initAddPayment frequency =
- { name = ""
- , nameError = Nothing
- , cost = ""
- , costError = Nothing
- , frequency = frequency
- }
-
-validateName : String -> Translations -> Result String String
-validateName name translations =
- name
- |> validateNonEmpty (getMessage "CategoryRequired" translations)
-
-validateCost : String -> Translations -> Result String Int
-validateCost cost translations =
- cost
- |> validateNonEmpty (getMessage "CostRequired" translations)
- |> flip Result.andThen (validateNumber (getMessage "CostMustBeNonNullNumber" translations) ((/=) 0))
-
-type Frequency = Punctual | Monthly
diff --git a/src/client/Model/View/LoggedIn/Edition.elm b/src/client/Model/View/LoggedIn/Edition.elm
deleted file mode 100644
index da6d7b0..0000000
--- a/src/client/Model/View/LoggedIn/Edition.elm
+++ /dev/null
@@ -1,7 +0,0 @@
-module Model.View.LoggedIn.Edition
- ( Edition
- ) where
-
-import Model.Payment exposing (PaymentId)
-
-type alias Edition = PaymentId
diff --git a/src/client/Model/View/LoggedIn/Monthly.elm b/src/client/Model/View/LoggedIn/Monthly.elm
deleted file mode 100644
index 3c6f66a..0000000
--- a/src/client/Model/View/LoggedIn/Monthly.elm
+++ /dev/null
@@ -1,17 +0,0 @@
-module Model.View.LoggedIn.Monthly
- ( Monthly
- , initMonthly
- ) where
-
-import Model.Payment exposing (Payments)
-
-type alias Monthly =
- { payments : Payments
- , visibleDetail : Bool
- }
-
-initMonthly : Payments -> Monthly
-initMonthly payments =
- { payments = payments
- , visibleDetail = False
- }
diff --git a/src/client/Model/View/LoggedInView.elm b/src/client/Model/View/LoggedInView.elm
deleted file mode 100644
index 122c4be..0000000
--- a/src/client/Model/View/LoggedInView.elm
+++ /dev/null
@@ -1,35 +0,0 @@
-module Model.View.LoggedInView
- ( LoggedInView
- , initLoggedInView
- ) where
-
-import Model.User exposing (Users, UserId)
-import Model.Payment exposing (Payments)
-import Model.Payer exposing (Payers)
-import Model.View.LoggedIn.Add exposing (..)
-import Model.View.LoggedIn.Edition exposing (..)
-import Model.View.LoggedIn.Monthly exposing (..)
-import Model.View.LoggedIn.Account exposing (..)
-
-type alias LoggedInView =
- { users : Users
- , add : AddPayment
- , monthly : Monthly
- , account : Account
- , payments : Payments
- , paymentsCount : Int
- , paymentEdition : Maybe Edition
- , currentPage : Int
- }
-
-initLoggedInView : Users -> UserId -> Payments -> Payments -> Int -> Payers -> LoggedInView
-initLoggedInView users me monthlyPayments payments paymentsCount payers =
- { users = users
- , add = initAddPayment Punctual
- , monthly = initMonthly monthlyPayments
- , account = initAccount me payers
- , payments = payments
- , paymentsCount = paymentsCount
- , paymentEdition = Nothing
- , currentPage = 1
- }
diff --git a/src/client/Model/View/SignInView.elm b/src/client/Model/View/SignInView.elm
deleted file mode 100644
index 0fbce39..0000000
--- a/src/client/Model/View/SignInView.elm
+++ /dev/null
@@ -1,15 +0,0 @@
-module Model.View.SignInView
- ( SignInView
- , initSignInView
- ) where
-
-type alias SignInView =
- { login : String
- , result : Maybe (Result String String)
- }
-
-initSignInView : SignInView
-initSignInView =
- { login = ""
- , result = Nothing
- }