aboutsummaryrefslogtreecommitdiff
path: root/client/src/View/Payment
diff options
context:
space:
mode:
authorJoris2019-10-20 22:08:31 +0200
committerJoris2019-10-20 22:08:31 +0200
commit33e78f2ebbf5bf7b40e7aa732cc7c019f6df3f12 (patch)
treebc325950963bcb5c27e1aaba2a4ee7e092efbcd4 /client/src/View/Payment
parent602c52acfcfa494b07fec05c20b317b60ea8a6f3 (diff)
Simplify page initialization
Diffstat (limited to 'client/src/View/Payment')
-rw-r--r--client/src/View/Payment/Pages.hs2
-rw-r--r--client/src/View/Payment/Payment.hs27
-rw-r--r--client/src/View/Payment/Table.hs2
3 files changed, 10 insertions, 21 deletions
diff --git a/client/src/View/Payment/Pages.hs b/client/src/View/Payment/Pages.hs
index 9247143..5681935 100644
--- a/client/src/View/Payment/Pages.hs
+++ b/client/src/View/Payment/Pages.hs
@@ -11,8 +11,8 @@ import qualified Reflex.Dom as R
import Component (ButtonIn (..), ButtonOut (..))
import qualified Component as Component
-import qualified Icon
import qualified Util.Reflex as ReflexUtil
+import qualified View.Icon as Icon
data PagesIn t = PagesIn
{ _pagesIn_total :: Dynamic t Int
diff --git a/client/src/View/Payment/Payment.hs b/client/src/View/Payment/Payment.hs
index ec350e2..5f0d03c 100644
--- a/client/src/View/Payment/Payment.hs
+++ b/client/src/View/Payment/Payment.hs
@@ -17,8 +17,8 @@ import Common.Model (Currency, Frequency, Income (..),
UserId)
import qualified Common.Util.Text as T
-import Model.Loadable (Loadable (..))
-import qualified Model.Loadable as Loadable
+import Loadable (Loadable (..))
+import qualified Loadable
import qualified Util.Ajax as AjaxUtil
import View.Payment.Header (HeaderIn (..), HeaderOut (..))
import qualified View.Payment.Header as Header
@@ -30,23 +30,11 @@ import qualified View.Payment.Table as Table
init :: forall t m. MonadWidget t m => m (Dynamic t (Loadable Init))
init = do
- postBuild <- R.getPostBuild
-
- incomesEvent <- AjaxUtil.get (R.tag (R.constant "api/incomes") postBuild)
- incomes <- Loadable.fromEvent incomesEvent
-
- usersEvent <- AjaxUtil.get (R.tag (R.constant "api/users") postBuild)
- users <- Loadable.fromEvent usersEvent
-
- paymentsEvent <- AjaxUtil.get (R.tag (R.constant "api/payments") postBuild)
- payments <- Loadable.fromEvent paymentsEvent
-
- paymentCategoriesEvent <- AjaxUtil.get (R.tag (R.constant "api/paymentCategories") postBuild)
- paymentCategories <- Loadable.fromEvent paymentCategoriesEvent
-
- categoriesEvent <- AjaxUtil.get (R.tag (R.constant "api/categories") postBuild)
- categories <- Loadable.fromEvent categoriesEvent
-
+ users <- AjaxUtil.getNow "api/users"
+ payments <- AjaxUtil.getNow "api/payments"
+ incomes <- AjaxUtil.getNow "api/incomes"
+ categories <- AjaxUtil.getNow "api/categories"
+ paymentCategories <- AjaxUtil.getNow "api/paymentCategories"
return $ do
us <- users
ps <- payments
@@ -55,6 +43,7 @@ init = do
pcs <- paymentCategories
return $ Init <$> us <*> ps <*> is <*> cs <*> pcs
+
data PaymentIn t = PaymentIn
{ _paymentIn_currentUser :: UserId
, _paymentIn_currency :: Currency
diff --git a/client/src/View/Payment/Table.hs b/client/src/View/Payment/Table.hs
index 5ffa037..3a0a4bf 100644
--- a/client/src/View/Payment/Table.hs
+++ b/client/src/View/Payment/Table.hs
@@ -28,8 +28,8 @@ import qualified View.Payment.Delete as Delete
import qualified View.Payment.Edit as Edit
import View.Payment.Init (Init (..))
-import qualified Icon
import qualified Util.Reflex as ReflexUtil
+import qualified View.Icon as Icon
data TableIn t = TableIn
{ _tableIn_init :: Init