Updated products/prices data in member site settings

refs https://github.com/TryGhost/Team/issues/637
refs 75169b705b

With custom prices, Portal now needs to show all available custom prices in the UI as well as product's name and description in the Portal UI. This change adds product information to member site settings for Portal UI.
This commit is contained in:
Rishabh 2021-05-07 15:14:56 +05:30
parent 5628bb5f5a
commit 6c2869db61

View File

@ -85,9 +85,13 @@ const getDefaultProductPrices = async function () {
if (product) { if (product) {
const model = await membersService.api.productRepository.get({id: product.get('id')}, {withRelated: ['stripePrices']}); const model = await membersService.api.productRepository.get({id: product.get('id')}, {withRelated: ['stripePrices']});
const productData = model.toJSON(); const productData = model.toJSON();
return productData.stripePrices || []; const prices = productData.stripePrices || [];
return {
product: productData,
prices
};
} }
return []; return {};
}; };
const getMemberSiteData = async function (req, res) { const getMemberSiteData = async function (req, res) {
@ -99,7 +103,7 @@ const getMemberSiteData = async function (req, res) {
if (!supportAddress.includes('@')) { if (!supportAddress.includes('@')) {
supportAddress = `${supportAddress}@${blogDomain}`; supportAddress = `${supportAddress}@${blogDomain}`;
} }
const defaultPrices = await getDefaultProductPrices(); const {product = {}, prices = []} = await getDefaultProductPrices() || {};
const response = { const response = {
title: settingsCache.get('title'), title: settingsCache.get('title'),
description: settingsCache.get('description'), description: settingsCache.get('description'),
@ -109,7 +113,11 @@ const getMemberSiteData = async function (req, res) {
url: urlUtils.urlFor('home', true), url: urlUtils.urlFor('home', true),
version: ghostVersion.safe, version: ghostVersion.safe,
plans: membersService.config.getPublicPlans(), plans: membersService.config.getPublicPlans(),
prices: defaultPrices, prices,
product: {
name: product.name || '',
description: product.description || ''
},
allow_self_signup: membersService.config.getAllowSelfSignup(), allow_self_signup: membersService.config.getAllowSelfSignup(),
members_signup_access: settingsCache.get('members_signup_access'), members_signup_access: settingsCache.get('members_signup_access'),
is_stripe_configured: isStripeConfigured, is_stripe_configured: isStripeConfigured,