aboutsummaryrefslogtreecommitdiff
path: root/client/src/View
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/View')
-rw-r--r--client/src/View/App.hs3
-rw-r--r--client/src/View/Income/Income.hs24
-rw-r--r--client/src/View/Income/Table.hs3
3 files changed, 9 insertions, 21 deletions
diff --git a/client/src/View/App.hs b/client/src/View/App.hs
index 1e26417..d305d00 100644
--- a/client/src/View/App.hs
+++ b/client/src/View/App.hs
@@ -67,11 +67,10 @@ signedWidget init route = do
}
IncomeRoute -> do
- incomeInit <- Income.init
Income.view $ Income.In
{ Income._in_currentUser = _init_currentUser init
, Income._in_currency = _init_currency init
- , Income._in_init = incomeInit
+ , Income._in_users = _init_users init
}
NotFoundRoute ->
diff --git a/client/src/View/Income/Income.hs b/client/src/View/Income/Income.hs
index fedf3d8..d31775a 100644
--- a/client/src/View/Income/Income.hs
+++ b/client/src/View/Income/Income.hs
@@ -1,20 +1,18 @@
{-# LANGUAGE ExplicitForAll #-}
module View.Income.Income
- ( init
- , view
+ ( view
, In(..)
) where
-import qualified Data.Text as T
import Data.Aeson (FromJSON)
import qualified Data.Maybe as Maybe
-import Prelude hiding (init)
+import qualified Data.Text as T
import Reflex.Dom (Dynamic, Event, MonadWidget)
import qualified Reflex.Dom as R
import Common.Model (Currency, Income (..),
- IncomesAndCount (..), UserId)
+ IncomesAndCount (..), User, UserId)
import qualified Component.Pages as Pages
import Loadable (Loadable (..))
@@ -27,22 +25,11 @@ import qualified View.Income.Reducer as Reducer
import qualified View.Income.Table as Table
data In t = In
- { _in_currentUser :: UserId
+ { _in_users :: [User]
+ , _in_currentUser :: UserId
, _in_currency :: Currency
- , _in_init :: Dynamic t (Loadable Init)
}
-init :: forall t m. MonadWidget t m => m (Dynamic t (Loadable Init))
-init = do
- users <- AjaxUtil.getNow "api/users"
- incomes <- AjaxUtil.getNow "api/incomes"
- payments <- AjaxUtil.getNow "api/payments"
- return $ do
- us <- users
- is <- incomes
- ps <- payments
- return $ Init <$> us <*> is <*> ps
-
view :: forall t m. MonadWidget t m => In t -> m ()
view input = do
rec
@@ -69,6 +56,7 @@ view input = do
{ Table._in_currentUser = _in_currentUser input
, Table._in_currency = _in_currency input
, Table._in_incomes = incomes
+ , Table._in_users = _in_users input
}
pages <- Pages.view $ Pages.In
diff --git a/client/src/View/Income/Table.hs b/client/src/View/Income/Table.hs
index 9b2129f..32ab27b 100644
--- a/client/src/View/Income/Table.hs
+++ b/client/src/View/Income/Table.hs
@@ -27,6 +27,7 @@ data In t = In
{ _in_currentUser :: UserId
, _in_currency :: Currency
, _in_incomes :: [Income]
+ , _in_users :: [User]
}
data Out t = Out
@@ -41,7 +42,7 @@ view input = do
table <- Table.view $ Table.In
{ Table._in_headerLabel = headerLabel
, Table._in_rows = reverse . L.sortOn _income_date $ _in_incomes input
- , Table._in_cell = cell [] (_in_currency input)
+ , Table._in_cell = cell (_in_users input) (_in_currency input)
, Table._in_cloneModal = \income ->
Form.view $ Form.In
{ Form._in_operation = Form.Clone income