aboutsummaryrefslogtreecommitdiff
path: root/client/src/View/Payment/Add.hs
diff options
context:
space:
mode:
authorJoris2019-08-08 21:28:22 +0200
committerJoris2019-08-08 21:28:22 +0200
commit7c77e52faa71e43324087903c905f9d493b1dfb7 (patch)
tree5bf5096cbfaaec0ea851f49e5022ed1ecfd17657 /client/src/View/Payment/Add.hs
parentfc8be14dd0089eb12b78af7aaaecd8ed57896677 (diff)
downloadbudget-7c77e52faa71e43324087903c905f9d493b1dfb7.tar.gz
budget-7c77e52faa71e43324087903c905f9d493b1dfb7.tar.bz2
budget-7c77e52faa71e43324087903c905f9d493b1dfb7.zip
Finish payment add modal
Diffstat (limited to 'client/src/View/Payment/Add.hs')
-rw-r--r--client/src/View/Payment/Add.hs36
1 files changed, 16 insertions, 20 deletions
diff --git a/client/src/View/Payment/Add.hs b/client/src/View/Payment/Add.hs
index d023613..e0772f7 100644
--- a/client/src/View/Payment/Add.hs
+++ b/client/src/View/Payment/Add.hs
@@ -66,7 +66,7 @@ view addIn = do
, _inputIn_validation = PaymentValidation.name
})
reset
- validate
+ confirm
cost <- _inputOut_value <$> (Component.input
(Component.defaultInputIn
@@ -74,7 +74,7 @@ view addIn = do
, _inputIn_validation = PaymentValidation.cost
})
reset
- validate)
+ confirm)
now <- liftIO Time.getCurrentTime
@@ -91,7 +91,7 @@ view addIn = do
, _inputIn_validation = PaymentValidation.date
})
(const currentDay <$> reset)
- validate)
+ confirm)
frequency <- _selectOut_value <$> (Component.select $ SelectIn
{ _selectIn_label = Msg.get Msg.Payment_Frequency
@@ -100,7 +100,7 @@ view addIn = do
, _selectIn_values = R.constDyn frequencies
, _selectIn_reset = reset
, _selectIn_isValid = const True
- , _selectIn_validate = validate
+ , _selectIn_validate = confirm
})
let setCategory =
@@ -115,7 +115,7 @@ view addIn = do
, _selectIn_values = R.constDyn categories
, _selectIn_reset = reset
, _selectIn_isValid = \id -> id /= -1
- , _selectIn_validate = validate
+ , _selectIn_validate = confirm
})
let payment = do
@@ -124,24 +124,20 @@ view addIn = do
d <- date
cat <- category
f <- frequency
- pure $ do
- n' <- n
- c' <- c
- d' <- d
- pure $ CreatePayment
- <$> ValidationUtil.nelError n'
- <*> ValidationUtil.nelError c'
- <*> ValidationUtil.nelError d'
- <*> ValidationUtil.nelError (V.Success cat)
- <*> ValidationUtil.nelError (V.Success f)
-
- (addPayment, cancel, validate) <- R.divClass "buttons" $ do
+ return (CreatePayment
+ <$> ValidationUtil.nelError n
+ <*> ValidationUtil.nelError c
+ <*> ValidationUtil.nelError d
+ <*> ValidationUtil.nelError cat
+ <*> ValidationUtil.nelError f)
+
+ (addPayment, cancel, confirm) <- R.divClass "buttons" $ do
rec
cancel <- Component._buttonOut_clic <$> (Component.button $
(Component.defaultButtonIn (R.text $ Msg.get Msg.Dialog_Undo))
{ _buttonIn_class = R.constDyn "undo" })
- validate <- Component._buttonOut_clic <$> (Component.button $
+ confirm <- Component._buttonOut_clic <$> (Component.button $
(Component.defaultButtonIn (R.text $ Msg.get Msg.Dialog_Confirm))
{ _buttonIn_class = R.constDyn "confirm"
, _buttonIn_waiting = waiting
@@ -150,9 +146,9 @@ view addIn = do
(addPayment, waiting) <- WaitFor.waitFor
(Ajax.postJson "/payment")
- (ValidationUtil.fireValidation payment validate)
+ (ValidationUtil.fireValidation payment confirm)
- return (R.fmapMaybe EitherUtil.eitherToMaybe addPayment, cancel, validate)
+ return (R.fmapMaybe EitherUtil.eitherToMaybe addPayment, cancel, confirm)
return AddOut
{ _addOut_cancel = cancel