aboutsummaryrefslogtreecommitdiff
path: root/client/src/View/Payment
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/View/Payment')
-rw-r--r--client/src/View/Payment/Add.hs35
-rw-r--r--client/src/View/Payment/Clone.hs35
-rw-r--r--client/src/View/Payment/Edit.hs27
-rw-r--r--client/src/View/Payment/Form.hs12
-rw-r--r--client/src/View/Payment/Header.hs3
5 files changed, 55 insertions, 57 deletions
diff --git a/client/src/View/Payment/Add.hs b/client/src/View/Payment/Add.hs
index e83dba9..28c0148 100644
--- a/client/src/View/Payment/Add.hs
+++ b/client/src/View/Payment/Add.hs
@@ -3,23 +3,22 @@ module View.Payment.Add
, Input(..)
) where
-import Control.Monad (join)
-import Control.Monad.IO.Class (liftIO)
-import qualified Data.Text as T
-import qualified Data.Time.Clock as Time
-import Reflex.Dom (Dynamic, Event, MonadWidget)
-import qualified Reflex.Dom as R
-
-import Common.Model (Category (..), CreatePayment (..),
- Frequency (..), Payment (..),
- PaymentCategory (..),
- SavedPayment (..))
-import qualified Common.Msg as Msg
-import qualified Common.Util.Time as TimeUtil
-import qualified Common.Validation.Payment as PaymentValidation
-import qualified Component.Modal as Modal
-import qualified Util.Reflex as ReflexUtil
-import qualified View.Payment.Form as Form
+import Control.Monad (join)
+import Control.Monad.IO.Class (liftIO)
+import qualified Data.Text as T
+import qualified Data.Time.Clock as Time
+import Reflex.Dom (Dynamic, Event, MonadWidget)
+import qualified Reflex.Dom as R
+
+import Common.Model (Category (..), CreatePaymentForm (..),
+ Frequency (..), Payment (..),
+ PaymentCategory (..),
+ SavedPayment (..))
+import qualified Common.Msg as Msg
+import qualified Common.Util.Time as TimeUtil
+import qualified Component.Modal as Modal
+import qualified Util.Reflex as ReflexUtil
+import qualified View.Payment.Form as Form
data Input t = Input
{ _input_categories :: [Category]
@@ -45,7 +44,7 @@ view input cancel = do
, Form._input_date = currentDay
, Form._input_category = -1
, Form._input_frequency = frequency
- , Form._input_mkPayload = CreatePayment
+ , Form._input_mkPayload = CreatePaymentForm
, Form._input_httpMethod = Form.Post
}
diff --git a/client/src/View/Payment/Clone.hs b/client/src/View/Payment/Clone.hs
index 922e89c..60694ca 100644
--- a/client/src/View/Payment/Clone.hs
+++ b/client/src/View/Payment/Clone.hs
@@ -3,23 +3,22 @@ module View.Payment.Clone
, view
) where
-import qualified Control.Monad as Monad
-import Control.Monad.IO.Class (liftIO)
-import qualified Data.Text as T
-import qualified Data.Time.Clock as Time
-import Reflex.Dom (Dynamic, Event, MonadWidget)
-import qualified Reflex.Dom as R
-
-import Common.Model (Category (..), CategoryId,
- CreatePayment (..), Frequency (..),
- Payment (..), PaymentCategory (..),
- SavedPayment (..))
-import qualified Common.Msg as Msg
-import qualified Common.Util.Time as TimeUtil
-import qualified Common.Validation.Payment as PaymentValidation
-import qualified Component.Modal as Modal
-import qualified Util.Reflex as ReflexUtil
-import qualified View.Payment.Form as Form
+import qualified Control.Monad as Monad
+import Control.Monad.IO.Class (liftIO)
+import qualified Data.Text as T
+import qualified Data.Time.Clock as Time
+import Reflex.Dom (Dynamic, Event, MonadWidget)
+import qualified Reflex.Dom as R
+
+import Common.Model (Category (..), CategoryId,
+ CreatePaymentForm (..), Frequency (..),
+ Payment (..), PaymentCategory (..),
+ SavedPayment (..))
+import qualified Common.Msg as Msg
+import qualified Common.Util.Time as TimeUtil
+import qualified Component.Modal as Modal
+import qualified Util.Reflex as ReflexUtil
+import qualified View.Payment.Form as Form
data Input t = Input
{ _input_show :: Event t ()
@@ -48,7 +47,7 @@ view input cancel = do
, Form._input_date = currentDay
, Form._input_category = category
, Form._input_frequency = _payment_frequency payment
- , Form._input_mkPayload = CreatePayment
+ , Form._input_mkPayload = CreatePaymentForm
, Form._input_httpMethod = Form.Post
}
diff --git a/client/src/View/Payment/Edit.hs b/client/src/View/Payment/Edit.hs
index 9c11af0..0361602 100644
--- a/client/src/View/Payment/Edit.hs
+++ b/client/src/View/Payment/Edit.hs
@@ -3,20 +3,19 @@ module View.Payment.Edit
, view
) where
-import qualified Control.Monad as Monad
-import qualified Data.Text as T
-import Reflex.Dom (Dynamic, Event, MonadWidget)
-import qualified Reflex.Dom as R
+import qualified Control.Monad as Monad
+import qualified Data.Text as T
+import Reflex.Dom (Dynamic, Event, MonadWidget)
+import qualified Reflex.Dom as R
-import Common.Model (Category (..), CategoryId,
- EditPayment (..), Frequency (..),
- Payment (..), PaymentCategory (..),
- SavedPayment (..))
-import qualified Common.Msg as Msg
-import qualified Common.Validation.Payment as PaymentValidation
-import qualified Component.Modal as Modal
-import qualified Util.Reflex as ReflexUtil
-import qualified View.Payment.Form as Form
+import Common.Model (Category (..), CategoryId,
+ EditPaymentForm (..), Frequency (..),
+ Payment (..), PaymentCategory (..),
+ SavedPayment (..))
+import qualified Common.Msg as Msg
+import qualified Component.Modal as Modal
+import qualified Util.Reflex as ReflexUtil
+import qualified View.Payment.Form as Form
data Input t = Input
{ _input_show :: Event t ()
@@ -43,7 +42,7 @@ view input cancel = do
, Form._input_date = _payment_date payment
, Form._input_category = category
, Form._input_frequency = _payment_frequency payment
- , Form._input_mkPayload = EditPayment (_payment_id payment)
+ , Form._input_mkPayload = EditPaymentForm (_payment_id payment)
, Form._input_httpMethod = Form.Put
}
diff --git a/client/src/View/Payment/Form.hs b/client/src/View/Payment/Form.hs
index 9889638..187b64b 100644
--- a/client/src/View/Payment/Form.hs
+++ b/client/src/View/Payment/Form.hs
@@ -46,7 +46,7 @@ data Input t p = Input
, _input_date :: Day
, _input_category :: CategoryId
, _input_frequency :: Frequency
- , _input_mkPayload :: Text -> Int -> Day -> CategoryId -> Frequency -> p
+ , _input_mkPayload :: Text -> Text -> Text -> CategoryId -> Frequency -> p
, _input_httpMethod :: HttpMethod
}
@@ -80,7 +80,7 @@ view input = do
(_input_name input <$ reset)
confirm
- cost <- _inputOut_value <$> (Component.input
+ cost <- _inputOut_raw <$> (Component.input
(Component.defaultInputIn
{ _inputIn_label = Msg.get Msg.Payment_Cost
, _inputIn_initialValue = _input_cost input
@@ -91,7 +91,7 @@ view input = do
let initialDate = T.pack . Calendar.showGregorian . _input_date $ input
- date <- _inputOut_value <$> (Component.input
+ date <- _inputOut_raw <$> (Component.input
(Component.defaultInputIn
{ _inputIn_label = Msg.get Msg.Payment_Date
, _inputIn_initialValue = initialDate
@@ -113,7 +113,7 @@ view input = do
, _selectIn_value = setCategory
, _selectIn_values = R.constDyn categories
, _selectIn_reset = _input_category input <$ reset
- , _selectIn_isValid = (/= -1)
+ , _selectIn_isValid = PaymentValidation.category (map _category_id $ _input_categories input)
, _selectIn_validate = confirm
})
@@ -124,8 +124,8 @@ view input = do
cat <- category
return ((_input_mkPayload input)
<$> ValidationUtil.nelError n
- <*> ValidationUtil.nelError c
- <*> ValidationUtil.nelError d
+ <*> V.Success c
+ <*> V.Success d
<*> ValidationUtil.nelError cat
<*> V.Success (_input_frequency input))
diff --git a/client/src/View/Payment/Header.hs b/client/src/View/Payment/Header.hs
index 7281195..6ed3b0e 100644
--- a/client/src/View/Payment/Header.hs
+++ b/client/src/View/Payment/Header.hs
@@ -13,6 +13,7 @@ import Data.Text (Text)
import qualified Data.Text as T
import Data.Time (NominalDiffTime)
import qualified Data.Time as Time
+import qualified Data.Validation as V
import Prelude hiding (init)
import Reflex.Dom (Dynamic, Event, MonadWidget, Reflex)
import qualified Reflex.Dom as R
@@ -150,7 +151,7 @@ searchLine reset = do
, _selectIn_value = R.never
, _selectIn_values = R.constDyn frequencies
, _selectIn_reset = R.never
- , _selectIn_isValid = const True
+ , _selectIn_isValid = V.Success
, _selectIn_validate = R.never
})