aboutsummaryrefslogtreecommitdiff
path: root/client/src/View/Income/Income.hs
diff options
context:
space:
mode:
authorJoris2019-11-03 11:28:42 +0100
committerJoris2019-11-03 11:28:42 +0100
commit9dbb4e6f7c2f0edc1126626e2ff498144c6b9947 (patch)
treeda352e0861a2786a3a57dab2397ec7d678b5919b /client/src/View/Income/Income.hs
parenta267f0bb4566389342c3244d3c082dc2453f4615 (diff)
downloadbudget-9dbb4e6f7c2f0edc1126626e2ff498144c6b9947.tar.gz
budget-9dbb4e6f7c2f0edc1126626e2ff498144c6b9947.tar.bz2
budget-9dbb4e6f7c2f0edc1126626e2ff498144c6b9947.zip
Show income header
Diffstat (limited to 'client/src/View/Income/Income.hs')
-rw-r--r--client/src/View/Income/Income.hs29
1 files changed, 18 insertions, 11 deletions
diff --git a/client/src/View/Income/Income.hs b/client/src/View/Income/Income.hs
index d31775a..d82ab4d 100644
--- a/client/src/View/Income/Income.hs
+++ b/client/src/View/Income/Income.hs
@@ -11,15 +11,15 @@ import qualified Data.Text as T
import Reflex.Dom (Dynamic, Event, MonadWidget)
import qualified Reflex.Dom as R
-import Common.Model (Currency, Income (..),
- IncomesAndCount (..), User, UserId)
+import Common.Model (Currency, Income (..), IncomePage (..),
+ User, UserId)
import qualified Component.Pages as Pages
import Loadable (Loadable (..))
import qualified Loadable
import qualified Util.Ajax as AjaxUtil
import qualified Util.Reflex as ReflexUtil
--- import qualified View.Income.Header as Header
+import qualified View.Income.Header as Header
import View.Income.Init (Init (..))
import qualified View.Income.Reducer as Reducer
import qualified View.Income.Table as Table
@@ -36,22 +36,29 @@ view input = do
incomes <- Reducer.reducer $ Reducer.In
{ Reducer._in_newPage = newPage
, Reducer._in_currentPage = currentPage
- , Reducer._in_addIncome = addIncome
+ , Reducer._in_addIncome = R.leftmost [headerAddIncome, tableAddIncome]
, Reducer._in_editIncome = editIncome
, Reducer._in_deleteIncome = deleteIncome
}
- let eventFromResult :: forall a. ((Table.Out t, Pages.Out t) -> Event t a) -> m (Event t a)
+ let eventFromResult :: forall a. ((Header.Out t, Table.Out t, Pages.Out t) -> Event t a) -> m (Event t a)
eventFromResult op = ReflexUtil.flatten . fmap (Maybe.fromMaybe R.never . fmap op) $ result
- newPage <- eventFromResult $ Pages._out_newPage . snd
+ newPage <- eventFromResult $ Pages._out_newPage . (\(_, _, c) -> c)
currentPage <- R.holdDyn 1 newPage
- addIncome <- eventFromResult $ Table._out_add . fst
- editIncome <- eventFromResult $ Table._out_edit . fst
- deleteIncome <- eventFromResult $ Table._out_delete . fst
+ headerAddIncome <- eventFromResult $ Header._out_add . (\(a, _, _) -> a)
+ tableAddIncome <- eventFromResult $ Table._out_add . (\(_, b, _) -> b)
+ editIncome <- eventFromResult $ Table._out_edit . (\(_, b, _) -> b)
+ deleteIncome <- eventFromResult $ Table._out_delete . (\(_, b, _) -> b)
result <- R.dyn . R.ffor ((,) <$> incomes <*> currentPage) $ \(is, p) ->
- flip Loadable.view is $ \(IncomesAndCount incomes count) -> do
+ flip Loadable.view is $ \(IncomePage header incomes count) -> do
+ header <- Header.view $ Header.In
+ { Header._in_users = _in_users input
+ , Header._in_header = header
+ , Header._in_currency = _in_currency input
+ }
+
table <- Table.view $ Table.In
{ Table._in_currentUser = _in_currentUser input
, Table._in_currency = _in_currency input
@@ -65,6 +72,6 @@ view input = do
, Pages._in_page = p
}
- return (table, pages)
+ return (header, table, pages)
return ()