prepare cash buy
This commit is contained in:
parent
048fdaa4fa
commit
a39c83d5f7
6 changed files with 57 additions and 0 deletions
|
@ -56,6 +56,13 @@ type UserAPI =
|
||||||
:<|> "user" :> "create" :> Get '[HTML] UserNewPage
|
:<|> "user" :> "create" :> Get '[HTML] UserNewPage
|
||||||
:<|> "user" :> "create" :> ReqBody '[FormUrlEncoded] MT.UserSubmit
|
:<|> "user" :> "create" :> ReqBody '[FormUrlEncoded] MT.UserSubmit
|
||||||
:> Post '[HTML] UserSelectPage
|
:> Post '[HTML] UserSelectPage
|
||||||
|
:<|> "buy"
|
||||||
|
:> QueryParam "refine" MT.ProductRefine
|
||||||
|
:> Get '[HTML] CashBuyOverviewPage
|
||||||
|
:<|> "buy"
|
||||||
|
:> QueryParam "force" Bool
|
||||||
|
:> ReqBody '[FormUrlEncoded] [MT.PurchaseDetail]
|
||||||
|
:> Post '[HTML] CashBuyConfirmPage
|
||||||
:<|> "journal" :> QueryParam "page" Word
|
:<|> "journal" :> QueryParam "page" Word
|
||||||
:> Get '[HTML] JournalPage
|
:> Get '[HTML] JournalPage
|
||||||
:<|> "auth"
|
:<|> "auth"
|
||||||
|
@ -85,6 +92,8 @@ type UserAPI =
|
||||||
userManageAuthDeleteLink :<|>
|
userManageAuthDeleteLink :<|>
|
||||||
userNewLink :<|>
|
userNewLink :<|>
|
||||||
userNewPostLink :<|>
|
userNewPostLink :<|>
|
||||||
|
cashBuyLink :<|>
|
||||||
|
cashBuyPostLink :<|>
|
||||||
journalLink :<|>
|
journalLink :<|>
|
||||||
authLink :<|>
|
authLink :<|>
|
||||||
authPostLink :<|>
|
authPostLink :<|>
|
||||||
|
|
|
@ -74,6 +74,22 @@ buyControl mcookie uid pds forceBuy =
|
||||||
else
|
else
|
||||||
throwError (redirect303 $ userOverviewLink uid Nothing)
|
throwError (redirect303 $ userOverviewLink uid Nothing)
|
||||||
|
|
||||||
|
cashBuyOverviewControl
|
||||||
|
:: Maybe T.Text
|
||||||
|
-> Maybe MT.ProductRefine
|
||||||
|
-> UserHandler CashBuyOverviewPage
|
||||||
|
cashBuyOverviewControl mcookie mrefine = do
|
||||||
|
(ReadState l10n backend _) <- ask
|
||||||
|
let loc = localeFromCookie mcookie
|
||||||
|
eproducts <- liftIO $ runClientM
|
||||||
|
(productShortList
|
||||||
|
mrefine
|
||||||
|
)
|
||||||
|
backend
|
||||||
|
case eproducts of
|
||||||
|
Right prods ->
|
||||||
|
return $ cashBuyOverviewPage l10n loc mcookie prods
|
||||||
|
|
||||||
purchaseControl
|
purchaseControl
|
||||||
:: Maybe T.Text
|
:: Maybe T.Text
|
||||||
-> Int
|
-> Int
|
||||||
|
|
|
@ -80,6 +80,8 @@ userApp initState = serveWithContext userApi EmptyContext $
|
||||||
:<|> userManageAuthDeleteControl mcookie
|
:<|> userManageAuthDeleteControl mcookie
|
||||||
:<|> userNewControl mcookie
|
:<|> userNewControl mcookie
|
||||||
:<|> userNewPostControl mcookie
|
:<|> userNewPostControl mcookie
|
||||||
|
:<|> cashBuyOverviewControl mcookie
|
||||||
|
:<|> const (error "not yet implemented")
|
||||||
:<|> journalControl mcookie
|
:<|> journalControl mcookie
|
||||||
:<|> authControl mcookie
|
:<|> authControl mcookie
|
||||||
:<|> authPostControl mcookie
|
:<|> authPostControl mcookie
|
||||||
|
|
|
@ -19,3 +19,7 @@ type AuthPage = H.Html
|
||||||
type BuyConfirmPage = H.Html
|
type BuyConfirmPage = H.Html
|
||||||
|
|
||||||
type JournalPage = H.Html
|
type JournalPage = H.Html
|
||||||
|
|
||||||
|
type CashBuyOverviewPage = H.Html
|
||||||
|
|
||||||
|
type CashBuyConfirmPage = H.Html
|
||||||
|
|
|
@ -178,3 +178,25 @@ buyProductsForm l10n locale prods = do
|
||||||
$ H.toHtml $ translate "Proceed"
|
$ H.toHtml $ translate "Proceed"
|
||||||
where
|
where
|
||||||
translate = localize l10n locale . gettext
|
translate = localize l10n locale . gettext
|
||||||
|
|
||||||
|
cashBuyOverviewPage
|
||||||
|
:: L10n
|
||||||
|
-> Locale
|
||||||
|
-> Maybe T.Text
|
||||||
|
-> [MT.ProductShortOverview]
|
||||||
|
-> CashBuyOverviewPage
|
||||||
|
cashBuyOverviewPage l10n loc mcookie psos =
|
||||||
|
scaffold l10n loc mcookie (initPage $
|
||||||
|
translate "Matebeamter" <>
|
||||||
|
" - " <>
|
||||||
|
translate "Buy with Cash"
|
||||||
|
) $
|
||||||
|
H.form
|
||||||
|
H.! HA.method "post"
|
||||||
|
H.! HA.action ("/" <> fromString (
|
||||||
|
show $ linkURI $ cashBuyPostLink (Just False)
|
||||||
|
))
|
||||||
|
H.! HA.enctype "application/x-www-form-urlencoded"
|
||||||
|
$ buyProductsForm l10n loc psos
|
||||||
|
where
|
||||||
|
translate = localize l10n loc . gettext
|
||||||
|
|
|
@ -39,6 +39,10 @@ userSelectPage l10n locale uss mcookie =
|
||||||
" - " <>
|
" - " <>
|
||||||
translate "Home"
|
translate "Home"
|
||||||
) $ do
|
) $ do
|
||||||
|
H.a H.! HA.href ("/" <> fromString
|
||||||
|
(show $ linkURI $ cashBuyLink Nothing)
|
||||||
|
) $
|
||||||
|
H.toHtml $ translate "Buy with cash"
|
||||||
mapM_ (\(MT.UserSummary uid ident _) ->
|
mapM_ (\(MT.UserSummary uid ident _) ->
|
||||||
H.a H.! HA.href ("/" <> fromString (show $ linkURI $
|
H.a H.! HA.href ("/" <> fromString (show $ linkURI $
|
||||||
userOverviewLink uid Nothing)) $
|
userOverviewLink uid Nothing)) $
|
||||||
|
|
Loading…
Reference in a new issue