diff --git a/src/API.hs b/src/API.hs index edb4432..7b255db 100644 --- a/src/API.hs +++ b/src/API.hs @@ -77,6 +77,11 @@ type UserAPI = :<|> "product" :> "refill" :> ReqBody '[FormUrlEncoded] [MT.AmountRefill] :> Post '[HTML] ProductRefillPage + :<|> "product" :> "new" + :> Get '[HTML] ProductNewPage + :<|> "product" :> "new" + :> ReqBody '[FormUrlEncoded] ProductSubmit + :> Post '[HTML] UserOverviewPage :<|> "auth" :> QueryParam "destination" T.Text :> Get '[HTML] @@ -112,6 +117,8 @@ type UserAPI = productGetPriceListLink :<|> productGetRefillLink :<|> productPostRefillLink :<|> + productGetNewLink :<|> + productPostNewLink :<|> authLink :<|> authPostLink :<|> authLogoutLink diff --git a/src/Control/Product.hs b/src/Control/Product.hs index 4a7170d..b2c8165 100644 --- a/src/Control/Product.hs +++ b/src/Control/Product.hs @@ -91,3 +91,8 @@ productPostRefill mcookie refills = do redirectOverAuth (read <$> muser) (Just productGetRefillLink) Nothing where translate l10n loc = localize l10n loc . gettext + +productGetNew + :: Maybe T.Text + -> UserHandler ProductNewPage +productgetNew mcookie = do diff --git a/src/Main.hs b/src/Main.hs index b595e93..39a9fe5 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -87,7 +87,7 @@ userApp initState = serveWithContext userApi EmptyContext $ :<|> journalPostCheckControl mcookie :<|> productGetPriceList mcookie :<|> productGetRefill mcookie - :<|> (\_ _ -> error "not yet implemented") mcookie + :<|> productPostRefill mcookie :<|> authControl mcookie :<|> authPostControl mcookie :<|> authLogoutControl mcookie diff --git a/src/Types/Product.hs b/src/Types/Product.hs new file mode 100644 index 0000000..78f5ab8 --- /dev/null +++ b/src/Types/Product.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE DeriveGeneric #-} +module Types.Product where + +import GHC.Generics + +import qualified Data.Text as T + +data ProductSubmit = ProductSubmit + { productSubmitIdent :: T.Text + , productSubmitPrice :: Int + , productSubmitMl :: Int + , productSubmitAvatar :: Maybe Int + , productSubmitSupplier :: Maybe Int + , productSubmitMaxAmount :: Int + , productSubmitAmountPerCrate :: Int + , productSubmitPricePerCrate :: Maybe Int + , productSubmitArtNr :: Maybe T.Text + } deriving (Generic, Show) diff --git a/src/Types/Views.hs b/src/Types/Views.hs index 9ad1916..5539915 100644 --- a/src/Types/Views.hs +++ b/src/Types/Views.hs @@ -29,3 +29,5 @@ type CashBuyConfirmPage = H.Html type ProductPriceListPage = H.Html type ProductRefillPage = H.Html + +type productNewPage = H.Html diff --git a/src/View/Product.hs b/src/View/Product.hs index b2b5ba3..c34cf5f 100644 --- a/src/View/Product.hs +++ b/src/View/Product.hs @@ -150,3 +150,17 @@ productRefillPage l10n loc mcookie prodList = $ H.toHtml $ translate "Submit" where translate = localize l10n loc . gettext + +productNewPage + :: L10n + -> Locale + -> Maybe T.Text + -> ProductNewPage +productnewPage l10n loc mcookie = + scaffold l10n loc mcookie (initPage $ + translate "Matebeamter" <> + " - " <> + translate "Create new product" + ) $ do + where + translate = localize l10n loc . gettext