aboutsummaryrefslogtreecommitdiff
path: root/client/src/View/Payment/Table.hs
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/View/Payment/Table.hs')
-rw-r--r--client/src/View/Payment/Table.hs21
1 files changed, 14 insertions, 7 deletions
diff --git a/client/src/View/Payment/Table.hs b/client/src/View/Payment/Table.hs
index bf6b604..5ffa037 100644
--- a/client/src/View/Payment/Table.hs
+++ b/client/src/View/Payment/Table.hs
@@ -13,10 +13,10 @@ import Prelude hiding (init)
import Reflex.Dom (Dynamic, Event, MonadWidget)
import qualified Reflex.Dom as R
-import Common.Model (Category (..), Frequency (Punctual),
- Init (..), Payment (..),
+import Common.Model (Category (..), Currency,
+ Frequency (Punctual), Payment (..),
PaymentCategory (..), SavedPayment,
- User (..))
+ User (..), UserId)
import qualified Common.Model as CM
import qualified Common.Msg as Msg
import qualified Common.View.Format as Format
@@ -26,12 +26,15 @@ import qualified Component.Modal as Modal
import qualified View.Payment.Clone as Clone
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
data TableIn t = TableIn
{ _tableIn_init :: Init
+ , _tableIn_currency :: Currency
+ , _tableIn_currentUser :: UserId
, _tableIn_currentPage :: Dynamic t Int
, _tableIn_payments :: Dynamic t [Payment]
, _tableIn_perPage :: Int
@@ -61,7 +64,7 @@ widget tableIn = do
R.divClass "cell" $ R.blank
result <-
- (R.simpleList paymentRange (paymentRow init paymentCategories))
+ (R.simpleList paymentRange (paymentRow init currency currentUser paymentCategories))
return $
( R.switch . R.current . fmap (R.leftmost . map (\(a, _, _) -> a)) $ result
@@ -80,6 +83,8 @@ widget tableIn = do
where
init = _tableIn_init tableIn
+ currency = _tableIn_currency tableIn
+ currentUser = _tableIn_currentUser tableIn
currentPage = _tableIn_currentPage tableIn
payments = _tableIn_payments tableIn
paymentRange = getPaymentRange (_tableIn_perPage tableIn) <$> payments <*> currentPage
@@ -96,17 +101,19 @@ getPaymentRange perPage payments currentPage =
paymentRow
:: forall t m. MonadWidget t m
=> Init
+ -> Currency
+ -> UserId
-> Dynamic t [PaymentCategory]
-> Dynamic t Payment
-> m (Event t SavedPayment, Event t SavedPayment, Event t Payment)
-paymentRow init paymentCategories payment =
+paymentRow init currency currentUser paymentCategories payment =
R.divClass "row" $ do
R.divClass "cell name" $
R.dynText $ fmap _payment_name payment
R.divClass "cell cost" $
- R.dynText $ fmap (Format.price (_init_currency init) . _payment_cost) payment
+ R.dynText $ fmap (Format.price currency . _payment_cost) payment
let user = R.ffor payment (\p ->
CM.findUser (_payment_user p) (_init_users init))
@@ -162,7 +169,7 @@ paymentRow init paymentCategories payment =
let isFromCurrentUser =
R.ffor
payment
- (\p -> _payment_user p == _init_currentUser init)
+ (\p -> _payment_user p == currentUser)
editPayment <-
R.divClass "cell button" $