aboutsummaryrefslogtreecommitdiff
path: root/client/src/View/Income/Income.hs
diff options
context:
space:
mode:
authorJoris2021-01-03 13:40:40 +0100
committerJoris2021-01-03 13:54:20 +0100
commit11052951b74b9ad4b6a9412ae490086235f9154b (patch)
tree64526ac926c1bf470ea113f6cac8a33158684e8d /client/src/View/Income/Income.hs
parent371449b0e312a03162b78797b83dee9d81706669 (diff)
downloadbudget-11052951b74b9ad4b6a9412ae490086235f9154b.tar.gz
budget-11052951b74b9ad4b6a9412ae490086235f9154b.tar.bz2
budget-11052951b74b9ad4b6a9412ae490086235f9154b.zip
Rewrite in Rust
Diffstat (limited to 'client/src/View/Income/Income.hs')
-rw-r--r--client/src/View/Income/Income.hs75
1 files changed, 0 insertions, 75 deletions
diff --git a/client/src/View/Income/Income.hs b/client/src/View/Income/Income.hs
deleted file mode 100644
index 7be8091..0000000
--- a/client/src/View/Income/Income.hs
+++ /dev/null
@@ -1,75 +0,0 @@
-{-# LANGUAGE ExplicitForAll #-}
-
-module View.Income.Income
- ( view
- , In(..)
- ) where
-
-import Data.Aeson (FromJSON)
-import qualified Data.Maybe as Maybe
-import qualified Data.Text as T
-import Reflex.Dom (Dynamic, Event, MonadWidget)
-import qualified Reflex.Dom as R
-
-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 Util.Reflex as ReflexUtil
-import qualified View.Income.Header as Header
-import qualified View.Income.Reducer as Reducer
-import qualified View.Income.Table as Table
-
-data In t = In
- { _in_users :: [User]
- , _in_currentUser :: UserId
- , _in_currency :: Currency
- }
-
-view :: forall t m. MonadWidget t m => In t -> m ()
-view input = do
- rec
- incomePage <- Reducer.reducer $ Reducer.In
- { Reducer._in_page = page
- , Reducer._in_addIncome = R.leftmost [headerAddIncome, tableAddIncome]
- , Reducer._in_editIncome = editIncome
- , Reducer._in_deleteIncome = deleteIncome
- }
-
- 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
-
- page <- eventFromResult $ Pages._out_newPage . (\(_, _, c) -> c)
- 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 <- Loadable.viewShowValueWhileLoading incomePage $
- \(IncomePage page 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
- , Table._in_incomes = incomes
- , Table._in_users = _in_users input
- }
-
- pages <- Pages.view $ Pages.In
- { Pages._in_total = R.constDyn count
- , Pages._in_perPage = Reducer.perPage
- , Pages._in_page = page
- }
-
- return (header, table, pages)
-
- return ()