blob: d83bb516ee7e6f9882f1ba7bb42a2128ec84131f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
module View.Income.Add
( view
) where
import Control.Monad.IO.Class (liftIO)
import qualified Data.Time.Clock as Time
import Reflex.Dom (MonadWidget)
import qualified Reflex.Dom as R
import Common.Model (CreateIncomeForm (..), Income)
import qualified Common.Msg as Msg
import qualified Common.Util.Time as TimeUtil
import qualified Component.Modal as Modal
import qualified Util.Reflex as ReflexUtil
import View.Income.Form (FormIn (..), FormOut (..))
import qualified View.Income.Form as Form
view :: forall t m. MonadWidget t m => Modal.Content t m Income
view cancel = do
currentDay <- liftIO $ Time.getCurrentTime >>= TimeUtil.timeToDay
form <- R.dyn $
return $ Form.view $ FormIn
{ _formIn_cancel = cancel
, _formIn_headerLabel = Msg.get Msg.Income_AddLong
, _formIn_amount = ""
, _formIn_date = currentDay
, _formIn_mkPayload = CreateIncomeForm
, _formIn_httpMethod = Form.Post
}
hide <- ReflexUtil.flatten (_formOut_hide <$> form)
addIncome <- ReflexUtil.flatten (_formOut_addIncome <$> form)
return (hide, addIncome)
|