2019-12-13 22:46:50 +00:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
{-# LANGUAGE PackageImports #-}
|
|
|
|
module View.Product where
|
|
|
|
|
2019-12-14 07:34:01 +00:00
|
|
|
import Data.String (fromString)
|
|
|
|
|
2019-12-13 22:46:50 +00:00
|
|
|
import qualified Data.Text as T
|
2019-12-14 07:34:01 +00:00
|
|
|
import Data.Text.I18n
|
2019-12-13 22:46:50 +00:00
|
|
|
|
|
|
|
import qualified Text.Blaze.Html5 as H
|
|
|
|
import qualified Text.Blaze.Html5.Attributes as HA
|
|
|
|
|
|
|
|
-- imports from "mateamt"
|
|
|
|
|
|
|
|
import qualified "mateamt" Types as MT
|
|
|
|
|
|
|
|
-- internal imports
|
|
|
|
|
|
|
|
import Types
|
|
|
|
import Util
|
|
|
|
import View.Scaffold
|
|
|
|
import API
|
|
|
|
|
|
|
|
productPriceListPage
|
|
|
|
:: L10n
|
|
|
|
-> Locale
|
2019-12-14 07:34:01 +00:00
|
|
|
-> Maybe T.Text
|
2019-12-13 22:46:50 +00:00
|
|
|
-> [MT.ProductShortOverview]
|
2019-12-14 07:34:01 +00:00
|
|
|
-> ProductPriceListPage
|
2019-12-13 22:46:50 +00:00
|
|
|
productPriceListPage l10n loc mcookie list =
|
|
|
|
scaffold l10n loc mcookie (initPage $
|
|
|
|
translate "Matebeamter" <>
|
|
|
|
" - " <>
|
|
|
|
translate "Price List"
|
|
|
|
) $ do
|
|
|
|
H.table $ do
|
|
|
|
H.thead $
|
|
|
|
H.tr $ do
|
|
|
|
H.th (H.toHtml $ translate "ID")
|
|
|
|
H.th (H.toHtml $ translate "Name")
|
|
|
|
H.th (H.toHtml $ translate "Amount")
|
|
|
|
H.th (H.toHtml $ translate "Volume")
|
|
|
|
H.th (H.toHtml $ translate "Price")
|
|
|
|
mapM_
|
|
|
|
(\(MT.ProductShortOverview pid ident price amount ml _) ->
|
|
|
|
H.tr $ do
|
|
|
|
H.td (H.toHtml $ show pid)
|
|
|
|
H.td (H.toHtml ident)
|
|
|
|
H.td (H.toHtml $ show amount)
|
2019-12-14 07:34:01 +00:00
|
|
|
H.td (H.toHtml $ (fromString $ show ml :: T.Text) <> " ml")
|
|
|
|
H.td (H.toHtml $ (formatMoney price)) -- TODO: Add Currency symbol
|
2019-12-13 22:46:50 +00:00
|
|
|
)
|
|
|
|
list
|
|
|
|
where
|
|
|
|
translate = localize l10n loc . gettext
|