46 lines
1 KiB
Haskell
46 lines
1 KiB
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
{-# LANGUAGE PackageImports #-}
|
|
module View.Product where
|
|
|
|
import Servant.Links
|
|
|
|
import qualified Text.Blaze.Html5 as H
|
|
import qualified Text.Blaze.Html5.Attributes as HA
|
|
|
|
import Data.Text.I18n
|
|
|
|
import Data.String (fromString)
|
|
|
|
-- imports from "mateamt"
|
|
|
|
import qualified "mateamt" Types as MT
|
|
|
|
-- internal imports
|
|
|
|
import Util
|
|
import Types
|
|
import View.Scaffold
|
|
import API
|
|
|
|
productListPage
|
|
:: L10n
|
|
-> Locale
|
|
-> Maybe MT.ProductRefine
|
|
-> [MT.ProductShortOverview]
|
|
-> ProductListPage
|
|
productListPage l10n locale mRefine psos = scaffold l10n locale (initPage $
|
|
(translate "Matebeamter") <>
|
|
" - " <>
|
|
(translate "Product list")
|
|
) $ if null psos
|
|
then
|
|
H.h1 $ H.toHtml $ translate "No products present"
|
|
else do
|
|
mapM_ (\(MT.ProductShortOverview pid ident price amount ml mAvatar) -> do
|
|
H.a H.! HA.href ("/" <> (fromString $ show $ linkURI $
|
|
productListLink mRefine)) $
|
|
H.toHtml ident
|
|
) psos
|
|
where
|
|
translate = localize l10n locale . gettext
|