preapre buy page(s)
This commit is contained in:
parent
18571fa201
commit
6ba45b564e
4 changed files with 127 additions and 116 deletions
|
@ -36,6 +36,7 @@ executable matebeamter
|
||||||
, View.Scaffold
|
, View.Scaffold
|
||||||
, View.Auth
|
, View.Auth
|
||||||
, View.User
|
, View.User
|
||||||
|
, View.Buy
|
||||||
-- other-extensions:
|
-- other-extensions:
|
||||||
build-depends: base ^>=4.12.0.0
|
build-depends: base ^>=4.12.0.0
|
||||||
, mateamt
|
, mateamt
|
||||||
|
|
|
@ -96,13 +96,18 @@ userOverviewControl mcookie uid mRefine = do
|
||||||
(token, mAuthUser) = parseTokenAndUser mcookie
|
(token, mAuthUser) = parseTokenAndUser mcookie
|
||||||
mMethod = T.unpack <$>
|
mMethod = T.unpack <$>
|
||||||
(lookup "x-method" =<< mParsedCookie)
|
(lookup "x-method" =<< mParsedCookie)
|
||||||
|
getProducts = liftIO $ runClientM
|
||||||
|
(productShortList mRefine)
|
||||||
|
backend
|
||||||
euser <- liftIO $
|
euser <- liftIO $
|
||||||
runClientM
|
runClientM
|
||||||
(userGet (mkAuthenticatedRequest token authenticateReq))
|
(userGet (mkAuthenticatedRequest token authenticateReq))
|
||||||
backend
|
backend
|
||||||
eproducts <- liftIO $ runClientM
|
eproducts <- case fmap toEnum (fmap read mMethod) of
|
||||||
(productShortList mRefine)
|
Just MT.PrimaryPass -> return (Right [])
|
||||||
backend
|
Just MT.SecondaryPass -> getProducts
|
||||||
|
Just MT.ChallengeResponse -> getProducts
|
||||||
|
_ -> return (Right [])
|
||||||
case (euser, eproducts) of
|
case (euser, eproducts) of
|
||||||
(Right ud, Right prods) ->
|
(Right ud, Right prods) ->
|
||||||
case mMethod of
|
case mMethod of
|
||||||
|
@ -210,7 +215,7 @@ userManageAuthDeleteControl
|
||||||
-> AuthDetailId
|
-> AuthDetailId
|
||||||
-> UserHandler UserOverviewPage
|
-> UserHandler UserOverviewPage
|
||||||
userManageAuthDeleteControl mcookie uid (AuthDetailId adid) = do
|
userManageAuthDeleteControl mcookie uid (AuthDetailId adid) = do
|
||||||
(ReadState _ backend _) <- ask
|
backend <- asks rsBackend
|
||||||
let (token, mAuthUser) = parseTokenAndUser mcookie
|
let (token, mAuthUser) = parseTokenAndUser mcookie
|
||||||
eReturn <- liftIO $ runClientM
|
eReturn <- liftIO $ runClientM
|
||||||
(authManageDeleteAuth (mkAuthenticatedRequest token authenticateReq) adid)
|
(authManageDeleteAuth (mkAuthenticatedRequest token authenticateReq) adid)
|
||||||
|
@ -221,7 +226,7 @@ userManageAuthDeleteControl mcookie uid (AuthDetailId adid) = do
|
||||||
FailureResponse _ resp ->
|
FailureResponse _ resp ->
|
||||||
if statusCode (responseStatusCode resp) == 406
|
if statusCode (responseStatusCode resp) == 406
|
||||||
then
|
then
|
||||||
throwError $ redirect303 $ userManageLink uid
|
throwError (redirect303 $ userManageLink uid)
|
||||||
else
|
else
|
||||||
handleErrors (fmap read mAuthUser) Nothing [Just err]
|
handleErrors (fmap read mAuthUser) Nothing [Just err]
|
||||||
_ -> handleErrors (fmap read mAuthUser) (Just userSelectLink) [Just err]
|
_ -> handleErrors (fmap read mAuthUser) (Just userSelectLink) [Just err]
|
||||||
|
|
12
src/Util.hs
12
src/Util.hs
|
@ -10,6 +10,8 @@ import Servant hiding (addHeader)
|
||||||
import Servant.Client
|
import Servant.Client
|
||||||
import Servant.Client.Core.Request
|
import Servant.Client.Core.Request
|
||||||
|
|
||||||
|
import qualified Text.Blaze.Html5.Attributes as HA
|
||||||
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Data.Text.Lazy.Encoding
|
import Data.Text.Lazy.Encoding
|
||||||
|
|
||||||
|
@ -131,3 +133,13 @@ redirectOverAuth muid mLink mRefine = do
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
productBgStyle aid = HA.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;"
|
||||||
|
]
|
||||||
|
|
|
@ -24,6 +24,7 @@ import qualified "mateamt" Types as MT
|
||||||
import Util
|
import Util
|
||||||
import Types
|
import Types
|
||||||
import View.Scaffold
|
import View.Scaffold
|
||||||
|
import View.Buy
|
||||||
import API
|
import API
|
||||||
|
|
||||||
userSelectPage
|
userSelectPage
|
||||||
|
@ -79,10 +80,10 @@ userOverviewPage l10n locale method ud pos = scaffold l10n locale (initPage $
|
||||||
MT.PrimaryPass ->
|
MT.PrimaryPass ->
|
||||||
userSettingsPointer l10n locale (MT.userDetailsId ud)
|
userSettingsPointer l10n locale (MT.userDetailsId ud)
|
||||||
MT.SecondaryPass ->
|
MT.SecondaryPass ->
|
||||||
productList pos
|
buyProductsForm l10n locale pos
|
||||||
MT.ChallengeResponse -> do
|
MT.ChallengeResponse -> do
|
||||||
userSettingsPointer l10n locale (MT.userDetailsId ud)
|
userSettingsPointer l10n locale (MT.userDetailsId ud)
|
||||||
productList pos
|
buyProductsForm l10n locale pos
|
||||||
where
|
where
|
||||||
translate = localize l10n locale . gettext
|
translate = localize l10n locale . gettext
|
||||||
|
|
||||||
|
@ -113,16 +114,6 @@ productList pos =
|
||||||
H.toHtml ident
|
H.toHtml ident
|
||||||
)
|
)
|
||||||
pos
|
pos
|
||||||
where
|
|
||||||
productBgStyle aid = HA.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;"
|
|
||||||
]
|
|
||||||
|
|
||||||
userNewPage
|
userNewPage
|
||||||
:: L10n
|
:: L10n
|
||||||
|
@ -182,7 +173,8 @@ userManagePage l10n locale userDetails authOverviews =
|
||||||
translate "Matebeamter" <>
|
translate "Matebeamter" <>
|
||||||
" - " <>
|
" - " <>
|
||||||
translate "Manage user data"
|
translate "Manage user data"
|
||||||
) $ H.p $ H.form
|
) $ H.p $ do
|
||||||
|
H.form
|
||||||
H.! HA.method "post"
|
H.! HA.method "post"
|
||||||
H.! HA.action ("/" <>
|
H.! HA.action ("/" <>
|
||||||
fromString (show $ linkURI $
|
fromString (show $ linkURI $
|
||||||
|
@ -216,6 +208,7 @@ userManagePage l10n locale userDetails authOverviews =
|
||||||
H.! HA.type_ "submit"
|
H.! HA.type_ "submit"
|
||||||
$ H.toHtml $ translate "Submit"
|
$ H.toHtml $ translate "Submit"
|
||||||
H.p $ do
|
H.p $ do
|
||||||
|
H.toHtml $ translate "Authentication details"
|
||||||
mapM_
|
mapM_
|
||||||
(\(MT.AuthOverview aoid comment method) -> H.form
|
(\(MT.AuthOverview aoid comment method) -> H.form
|
||||||
H.! HA.method "post"
|
H.! HA.method "post"
|
||||||
|
@ -251,7 +244,7 @@ userManagePage l10n locale userDetails authOverviews =
|
||||||
fromString (show $ linkURI $
|
fromString (show $ linkURI $
|
||||||
userManageAuthCreateLink (MT.userDetailsId userDetails)))
|
userManageAuthCreateLink (MT.userDetailsId userDetails)))
|
||||||
H.! HA.enctype "application/x-www-form-urlencoded" $ H.fieldset $ do
|
H.! HA.enctype "application/x-www-form-urlencoded" $ H.fieldset $ do
|
||||||
H.legend $ H.toHtml $ translate "Authentication details"
|
H.legend $ H.toHtml $ translate "New authentication"
|
||||||
H.div H.! HA.class_ "form-group required" $ do
|
H.div H.! HA.class_ "form-group required" $ do
|
||||||
H.label H.! HA.for "comment" $ H.toHtml $
|
H.label H.! HA.for "comment" $ H.toHtml $
|
||||||
translate "Comment"
|
translate "Comment"
|
||||||
|
|
Loading…
Reference in a new issue