aboutsummaryrefslogtreecommitdiff
path: root/client/src/View/Payment/HeaderInfos.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/Payment/HeaderInfos.hs
parent371449b0e312a03162b78797b83dee9d81706669 (diff)
downloadbudget-11052951b74b9ad4b6a9412ae490086235f9154b.tar.gz
budget-11052951b74b9ad4b6a9412ae490086235f9154b.tar.bz2
budget-11052951b74b9ad4b6a9412ae490086235f9154b.zip
Rewrite in Rust
Diffstat (limited to 'client/src/View/Payment/HeaderInfos.hs')
-rw-r--r--client/src/View/Payment/HeaderInfos.hs94
1 files changed, 0 insertions, 94 deletions
diff --git a/client/src/View/Payment/HeaderInfos.hs b/client/src/View/Payment/HeaderInfos.hs
deleted file mode 100644
index f84ee1f..0000000
--- a/client/src/View/Payment/HeaderInfos.hs
+++ /dev/null
@@ -1,94 +0,0 @@
-module View.Payment.HeaderInfos
- ( view
- , In(..)
- ) where
-
-import Control.Monad.IO.Class (liftIO)
-import qualified Data.List as L hiding (groupBy)
-import Data.Map (Map)
-import qualified Data.Map as M
-import Data.Maybe (fromMaybe)
-import Data.Text (Text)
-import qualified Data.Text as T
-import qualified Data.Time as Time
-import Reflex.Dom (Dynamic, Event, MonadWidget)
-import qualified Reflex.Dom as R
-
-import Common.Model (Currency, ExceedingPayer (..),
- Payment (..), PaymentHeader (..),
- User (..), UserId)
-import qualified Common.Model as CM
-import qualified Common.Msg as Msg
-import qualified Common.View.Format as Format
-
-data In t = In
- { _in_users :: [User]
- , _in_currency :: Currency
- , _in_header :: PaymentHeader
- , _in_paymentCount :: Int
- }
-
-view :: forall t m. MonadWidget t m => In t -> m ()
-view input =
- R.divClass "g-PaymentHeaderInfos" $ do
- exceedingPayers
- (_in_users input)
- (_in_currency input)
- (_paymentHeader_exceedingPayers header)
-
- infos
- (_in_users input)
- (_in_currency input)
- (_paymentHeader_repartition header)
- (_in_paymentCount input)
-
- where
- header = _in_header input
-
-exceedingPayers
- :: forall t m. MonadWidget t m
- => [User]
- -> Currency
- -> [ExceedingPayer]
- -> m ()
-exceedingPayers users currency payers =
- R.divClass "g-PaymentHeaderInfos__ExceedingPayers" $
- flip mapM_ payers $ \payer ->
- R.elClass "span" "exceedingPayer" $ do
- R.elClass "span" "userName" $
- R.text $
- fromMaybe "" . fmap _user_name $ CM.findUser (_exceedingPayer_userId payer) users
- R.elClass "span" "amount" $ do
- R.text "+ "
- R.text . Format.price currency $ _exceedingPayer_amount payer
-
-infos
- :: forall t m. MonadWidget t m
- => [User]
- -> Currency
- -> Map UserId Int
- -> Int
- -> m ()
-infos users currency repartition paymentCount =
- R.divClass "g-PaymentHeaderInfos__Repartition" $ do
-
- R.elClass "span" "total" $ do
- R.text $
- Msg.get $ Msg.Payment_Worth
- (T.intercalate " "
- [ (Format.number paymentCount)
- , if paymentCount > 1
- then Msg.get Msg.Payment_Many
- else Msg.get Msg.Payment_One
- ])
- (Format.price currency (M.foldl (+) 0 repartition))
-
- R.elClass "span" "partition" . R.text $
- let totalByUser =
- L.sortBy (\(_, t1) (_, t2) -> compare t2 t1)
- . M.toList
- $ repartition
- in T.intercalate ", " . flip map totalByUser $ \(userId, userTotal) ->
- Msg.get $ Msg.Payment_By
- (fromMaybe "" . fmap _user_name $ CM.findUser userId users)
- (Format.price currency userTotal)