2019-09-08 10:48:57 +00:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2019-09-08 15:27:38 +00:00
|
|
|
{-# LANGUAGE PackageImports #-}
|
2019-09-08 10:48:57 +00:00
|
|
|
module View.User where
|
|
|
|
|
2019-09-11 04:27:54 +00:00
|
|
|
import qualified Text.Blaze.Html5 as H hiding (style)
|
2019-09-08 15:27:38 +00:00
|
|
|
import qualified Text.Blaze.Html5.Attributes as H
|
|
|
|
|
|
|
|
import Data.Text.I18n
|
|
|
|
|
|
|
|
import Data.String (fromString)
|
|
|
|
|
2019-09-11 04:27:54 +00:00
|
|
|
import Data.Maybe (isJust, fromJust)
|
|
|
|
|
2019-09-08 15:27:38 +00:00
|
|
|
-- imports from mateamt
|
|
|
|
|
|
|
|
import qualified "mateamt" Types as MT
|
|
|
|
|
|
|
|
-- internal imports
|
2019-09-08 10:48:57 +00:00
|
|
|
|
2019-09-11 04:27:54 +00:00
|
|
|
import Util
|
2019-09-08 10:48:57 +00:00
|
|
|
import Types
|
2019-09-08 15:27:38 +00:00
|
|
|
import View.Scaffold
|
2019-09-08 10:48:57 +00:00
|
|
|
|
2019-09-11 04:27:54 +00:00
|
|
|
type UserSelectPage = H.Html
|
2019-09-08 10:48:57 +00:00
|
|
|
|
2019-09-11 04:27:54 +00:00
|
|
|
userSelectPage
|
2019-09-08 15:27:38 +00:00
|
|
|
:: L10n
|
|
|
|
-> Locale
|
|
|
|
-> [MT.UserSummary]
|
2019-09-11 04:27:54 +00:00
|
|
|
-> UserSelectPage
|
|
|
|
userSelectPage l10n locale uss = scaffold l10n locale (initPage $
|
|
|
|
(localize l10n locale $ gettext "Matebeamter") <>
|
|
|
|
" - " <>
|
|
|
|
(localize l10n locale $ gettext "Home")
|
|
|
|
) $ mapM_ (\(MT.UserSummary uid ident _) -> do
|
2019-09-08 15:27:38 +00:00
|
|
|
H.a H.! H.href ("#" <> fromString (show uid)) $ H.toHtml ident
|
|
|
|
) uss
|
|
|
|
|
2019-09-11 04:27:54 +00:00
|
|
|
type UserOverviewPage = H.Html
|
|
|
|
|
|
|
|
userOverviewPage
|
|
|
|
:: L10n
|
|
|
|
-> Locale
|
|
|
|
-> MT.UserDetails
|
|
|
|
-> [MT.ProductShortOverview]
|
|
|
|
-> UserOverviewPage
|
|
|
|
userOverviewPage l10n locale ud pos = scaffold l10n locale (initPage $
|
|
|
|
(localize l10n locale $ gettext "Matebeamter") <>
|
|
|
|
" - " <>
|
|
|
|
(localize l10n locale $ gettext "User Menu for ") <>
|
|
|
|
(MT.userDetailsIdent ud)
|
|
|
|
) $ do
|
|
|
|
H.p $ H.toHtml $ (translate "Welcome back, ") <> (MT.userDetailsIdent ud)
|
|
|
|
<> "!"
|
|
|
|
H.p H.!? (MT.userDetailsBalance ud < 0, H.class_ "debt") $ H.toHtml $
|
|
|
|
(translate "Your current balance is") <>
|
|
|
|
": " <>
|
|
|
|
(formatMoney $ MT.userDetailsBalance ud)
|
|
|
|
-- TODO: Add currency symbol
|
|
|
|
H.ul H.! H.class_ "product_list" $
|
|
|
|
mapM_
|
|
|
|
(\(MT.ProductShortOverview pid ident _ _ _ avatarid) -> do
|
|
|
|
H.li H.! H.class_ "product" H.!?
|
|
|
|
(isJust avatarid
|
|
|
|
, productBgStyle (fromString $ show $ fromJust avatarid)
|
|
|
|
) $
|
|
|
|
H.a H.! H.href ("#" <> fromString (show pid)) $ H.toHtml ident
|
|
|
|
)
|
|
|
|
pos
|
|
|
|
where
|
|
|
|
translate = localize l10n locale . gettext
|
|
|
|
productBgStyle aid = H.style $ mconcat
|
|
|
|
[ "background-image: url(#" <> aid <> ");" -- FILLME
|
|
|
|
, "backgronud-color: blue;"
|
|
|
|
, "text-shadow:"
|
|
|
|
, " -1px 0 1px black,"
|
|
|
|
, " 0 1px 1px black,"
|
|
|
|
, " 1px 0 1px black,"
|
|
|
|
, " 0 -1px 1px black;"
|
|
|
|
]
|