From e19f07c52115c7423bdf4fb586ce1288881b915a Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Sun, 27 Feb 2022 23:50:35 +0800 Subject: [PATCH] Add product detail page. --- object/product.go | 1 + web/src/App.js | 2 + web/src/ApplicationEditPage.js | 33 +++--- web/src/ProductBuyPage.js | 196 +++++++++++++++++++++++++++++++++ web/src/ProductEditPage.js | 35 ++++++ web/src/locales/de/data.json | 15 ++- web/src/locales/en/data.json | 15 ++- web/src/locales/fr/data.json | 15 ++- web/src/locales/ja/data.json | 15 ++- web/src/locales/ko/data.json | 15 ++- web/src/locales/ru/data.json | 15 ++- web/src/locales/zh/data.json | 17 ++- 12 files changed, 349 insertions(+), 25 deletions(-) create mode 100644 web/src/ProductBuyPage.js diff --git a/object/product.go b/object/product.go index 47d7d7d5..920e4e68 100644 --- a/object/product.go +++ b/object/product.go @@ -28,6 +28,7 @@ type Product struct { DisplayName string `xorm:"varchar(100)" json:"displayName"` Image string `xorm:"varchar(100)" json:"image"` + Detail string `xorm:"varchar(100)" json:"detail"` Tag string `xorm:"varchar(100)" json:"tag"` Currency string `xorm:"varchar(100)" json:"currency"` Price int `json:"price"` diff --git a/web/src/App.js b/web/src/App.js index 91803166..85955d3b 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -45,6 +45,7 @@ import CertListPage from "./CertListPage"; import CertEditPage from "./CertEditPage"; import ProductListPage from "./ProductListPage"; import ProductEditPage from "./ProductEditPage"; +import ProductBuyPage from "./ProductBuyPage"; import PaymentListPage from "./PaymentListPage"; import PaymentEditPage from "./PaymentEditPage"; import AccountPage from "./account/AccountPage"; @@ -503,6 +504,7 @@ class App extends Component { this.renderLoginIfNotLoggedIn()}/> this.renderLoginIfNotLoggedIn()}/> this.renderLoginIfNotLoggedIn()}/> + this.renderLoginIfNotLoggedIn()}/> this.renderLoginIfNotLoggedIn()}/> this.renderLoginIfNotLoggedIn()}/> this.renderLoginIfNotLoggedIn()}/> diff --git a/web/src/ApplicationEditPage.js b/web/src/ApplicationEditPage.js index cae41e5f..8259dc5c 100644 --- a/web/src/ApplicationEditPage.js +++ b/web/src/ApplicationEditPage.js @@ -443,7 +443,6 @@ class ApplicationEditPage extends React.Component { {Setting.getLabel(i18next.t("application:Grant types"), i18next.t("application:Grant types - Tooltip"))} : - { + this.updateProductField('detail', e.target.value); + }} /> + + {Setting.getLabel(i18next.t("product:Currency"), i18next.t("product:Currency - Tooltip"))} : @@ -218,10 +229,34 @@ class ProductEditPage extends React.Component { + + + {Setting.getLabel(i18next.t("general:Preview"), i18next.t("general:Preview - Tooltip"))} : + + { + this.renderPreview() + } + ) } + renderPreview() { + let buyUrl = `/products/${this.state.product.name}/buy`; + return ( + + + + +
+
+
+ +
+ + ) + } + submitProductEdit(willExist) { let product = Setting.deepCopy(this.state.product); ProductBackend.updateProduct(this.state.product.owner, this.state.productName, product) diff --git a/web/src/locales/de/data.json b/web/src/locales/de/data.json index e90477aa..4324dfee 100644 --- a/web/src/locales/de/data.json +++ b/web/src/locales/de/data.json @@ -272,22 +272,35 @@ "Resources": "Ressourcen" }, "product": { + "Alipay": "Alipay", + "Buy Product": "Buy Product", + "CNY": "CNY", "Currency": "Currency", "Currency - Tooltip": "Currency - Tooltip", + "Detail": "Detail", + "Detail - Tooltip": "Detail - Tooltip", "Edit Product": "Edit Product", "Image": "Image", "Image - Tooltip": "Image - Tooltip", "New Product": "New Product", + "Pay": "Pay", "Payment providers": "Payment providers", "Payment providers - Tooltip": "Payment providers - Tooltip", + "Paypal": "Paypal", "Price": "Price", "Price - Tooltip": "Price - Tooltip", "Quantity": "Quantity", "Quantity - Tooltip": "Quantity - Tooltip", + "SKU": "SKU", "Sold": "Sold", "Sold - Tooltip": "Sold - Tooltip", "Tag": "Tag", - "Tag - Tooltip": "Tag - Tooltip" + "Tag - Tooltip": "Tag - Tooltip", + "Test buy page..": "Test buy page..", + "There is no payment channel for this product.": "There is no payment channel for this product.", + "This product is currently not in sale.": "This product is currently not in sale.", + "USD": "USD", + "WeChat Pay": "WeChat Pay" }, "provider": { "Access key": "Zugangsschlüssel", diff --git a/web/src/locales/en/data.json b/web/src/locales/en/data.json index 37a7dfbe..0ab2eb02 100644 --- a/web/src/locales/en/data.json +++ b/web/src/locales/en/data.json @@ -272,22 +272,35 @@ "Resources": "Resources" }, "product": { + "Alipay": "Alipay", + "Buy Product": "Buy Product", + "CNY": "CNY", "Currency": "Currency", "Currency - Tooltip": "Currency - Tooltip", + "Detail": "Detail", + "Detail - Tooltip": "Detail - Tooltip", "Edit Product": "Edit Product", "Image": "Image", "Image - Tooltip": "Image - Tooltip", "New Product": "New Product", + "Pay": "Pay", "Payment providers": "Payment providers", "Payment providers - Tooltip": "Payment providers - Tooltip", + "Paypal": "Paypal", "Price": "Price", "Price - Tooltip": "Price - Tooltip", "Quantity": "Quantity", "Quantity - Tooltip": "Quantity - Tooltip", + "SKU": "SKU", "Sold": "Sold", "Sold - Tooltip": "Sold - Tooltip", "Tag": "Tag", - "Tag - Tooltip": "Tag - Tooltip" + "Tag - Tooltip": "Tag - Tooltip", + "Test buy page..": "Test buy page..", + "There is no payment channel for this product.": "There is no payment channel for this product.", + "This product is currently not in sale.": "This product is currently not in sale.", + "USD": "USD", + "WeChat Pay": "WeChat Pay" }, "provider": { "Access key": "Access key", diff --git a/web/src/locales/fr/data.json b/web/src/locales/fr/data.json index d8a34cd3..35882daa 100644 --- a/web/src/locales/fr/data.json +++ b/web/src/locales/fr/data.json @@ -272,22 +272,35 @@ "Resources": "Ressource" }, "product": { + "Alipay": "Alipay", + "Buy Product": "Buy Product", + "CNY": "CNY", "Currency": "Currency", "Currency - Tooltip": "Currency - Tooltip", + "Detail": "Detail", + "Detail - Tooltip": "Detail - Tooltip", "Edit Product": "Edit Product", "Image": "Image", "Image - Tooltip": "Image - Tooltip", "New Product": "New Product", + "Pay": "Pay", "Payment providers": "Payment providers", "Payment providers - Tooltip": "Payment providers - Tooltip", + "Paypal": "Paypal", "Price": "Price", "Price - Tooltip": "Price - Tooltip", "Quantity": "Quantity", "Quantity - Tooltip": "Quantity - Tooltip", + "SKU": "SKU", "Sold": "Sold", "Sold - Tooltip": "Sold - Tooltip", "Tag": "Tag", - "Tag - Tooltip": "Tag - Tooltip" + "Tag - Tooltip": "Tag - Tooltip", + "Test buy page..": "Test buy page..", + "There is no payment channel for this product.": "There is no payment channel for this product.", + "This product is currently not in sale.": "This product is currently not in sale.", + "USD": "USD", + "WeChat Pay": "WeChat Pay" }, "provider": { "Access key": "Clé d'accès", diff --git a/web/src/locales/ja/data.json b/web/src/locales/ja/data.json index f38511cc..98883a0d 100644 --- a/web/src/locales/ja/data.json +++ b/web/src/locales/ja/data.json @@ -272,22 +272,35 @@ "Resources": "リソース" }, "product": { + "Alipay": "Alipay", + "Buy Product": "Buy Product", + "CNY": "CNY", "Currency": "Currency", "Currency - Tooltip": "Currency - Tooltip", + "Detail": "Detail", + "Detail - Tooltip": "Detail - Tooltip", "Edit Product": "Edit Product", "Image": "Image", "Image - Tooltip": "Image - Tooltip", "New Product": "New Product", + "Pay": "Pay", "Payment providers": "Payment providers", "Payment providers - Tooltip": "Payment providers - Tooltip", + "Paypal": "Paypal", "Price": "Price", "Price - Tooltip": "Price - Tooltip", "Quantity": "Quantity", "Quantity - Tooltip": "Quantity - Tooltip", + "SKU": "SKU", "Sold": "Sold", "Sold - Tooltip": "Sold - Tooltip", "Tag": "Tag", - "Tag - Tooltip": "Tag - Tooltip" + "Tag - Tooltip": "Tag - Tooltip", + "Test buy page..": "Test buy page..", + "There is no payment channel for this product.": "There is no payment channel for this product.", + "This product is currently not in sale.": "This product is currently not in sale.", + "USD": "USD", + "WeChat Pay": "WeChat Pay" }, "provider": { "Access key": "アクセスキー", diff --git a/web/src/locales/ko/data.json b/web/src/locales/ko/data.json index e2dffea4..63b73cbb 100644 --- a/web/src/locales/ko/data.json +++ b/web/src/locales/ko/data.json @@ -272,22 +272,35 @@ "Resources": "Resources" }, "product": { + "Alipay": "Alipay", + "Buy Product": "Buy Product", + "CNY": "CNY", "Currency": "Currency", "Currency - Tooltip": "Currency - Tooltip", + "Detail": "Detail", + "Detail - Tooltip": "Detail - Tooltip", "Edit Product": "Edit Product", "Image": "Image", "Image - Tooltip": "Image - Tooltip", "New Product": "New Product", + "Pay": "Pay", "Payment providers": "Payment providers", "Payment providers - Tooltip": "Payment providers - Tooltip", + "Paypal": "Paypal", "Price": "Price", "Price - Tooltip": "Price - Tooltip", "Quantity": "Quantity", "Quantity - Tooltip": "Quantity - Tooltip", + "SKU": "SKU", "Sold": "Sold", "Sold - Tooltip": "Sold - Tooltip", "Tag": "Tag", - "Tag - Tooltip": "Tag - Tooltip" + "Tag - Tooltip": "Tag - Tooltip", + "Test buy page..": "Test buy page..", + "There is no payment channel for this product.": "There is no payment channel for this product.", + "This product is currently not in sale.": "This product is currently not in sale.", + "USD": "USD", + "WeChat Pay": "WeChat Pay" }, "provider": { "Access key": "Access key", diff --git a/web/src/locales/ru/data.json b/web/src/locales/ru/data.json index 2f053377..ecb7f0e4 100644 --- a/web/src/locales/ru/data.json +++ b/web/src/locales/ru/data.json @@ -272,22 +272,35 @@ "Resources": "Ресурсы" }, "product": { + "Alipay": "Alipay", + "Buy Product": "Buy Product", + "CNY": "CNY", "Currency": "Currency", "Currency - Tooltip": "Currency - Tooltip", + "Detail": "Detail", + "Detail - Tooltip": "Detail - Tooltip", "Edit Product": "Edit Product", "Image": "Image", "Image - Tooltip": "Image - Tooltip", "New Product": "New Product", + "Pay": "Pay", "Payment providers": "Payment providers", "Payment providers - Tooltip": "Payment providers - Tooltip", + "Paypal": "Paypal", "Price": "Price", "Price - Tooltip": "Price - Tooltip", "Quantity": "Quantity", "Quantity - Tooltip": "Quantity - Tooltip", + "SKU": "SKU", "Sold": "Sold", "Sold - Tooltip": "Sold - Tooltip", "Tag": "Tag", - "Tag - Tooltip": "Tag - Tooltip" + "Tag - Tooltip": "Tag - Tooltip", + "Test buy page..": "Test buy page..", + "There is no payment channel for this product.": "There is no payment channel for this product.", + "This product is currently not in sale.": "This product is currently not in sale.", + "USD": "USD", + "WeChat Pay": "WeChat Pay" }, "provider": { "Access key": "Ключ доступа", diff --git a/web/src/locales/zh/data.json b/web/src/locales/zh/data.json index 2cb028c8..ee951047 100644 --- a/web/src/locales/zh/data.json +++ b/web/src/locales/zh/data.json @@ -272,22 +272,35 @@ "Resources": "资源" }, "product": { + "Alipay": "支付宝", + "Buy Product": "购买商品", + "CNY": "人民币", "Currency": "币种", "Currency - Tooltip": "币种 - 工具提示", + "Detail": "详情", + "Detail - Tooltip": "详情 - 工具提示", "Edit Product": "编辑商品", "Image": "图片", "Image - Tooltip": "图片 - 工具提示", "New Product": "添加商品", + "Pay": "支付方式", "Payment providers": "支付提供商", "Payment providers - Tooltip": "支付提供商 - 工具提示", + "Paypal": "Paypal", "Price": "价格", "Price - Tooltip": "价格 - 工具提示", "Quantity": "库存", "Quantity - Tooltip": "库存 - 工具提示", + "SKU": "货号", "Sold": "售出", "Sold - Tooltip": "售出 - 工具提示", - "Tag": "标签", - "Tag - Tooltip": "标签 - 工具提示" + "Tag": "类别", + "Tag - Tooltip": "类别 - 工具提示", + "Test buy page..": "测试购买页面..", + "There is no payment channel for this product.": "该商品没有付款方式。", + "This product is currently not in sale.": "该商品目前未在售。", + "USD": "美元", + "WeChat Pay": "微信支付" }, "provider": { "Access key": "访问密钥",