@@ -585,7 +613,7 @@ export function MultipleProductsPlansSection({products, selectedPlan, onPlanSele
);
}
-export function SingleProductPlansSection({product, plans, showLabel = true, selectedPlan, onPlanSelect, changePlan = false}) {
+export function SingleProductPlansSection({product, plans, selectedPlan, onPlanSelect, changePlan = false}) {
const {site} = useContext(AppContext);
if (!product || hasOnlyFreePlan({plans})) {
return null;
@@ -609,6 +637,65 @@ export function SingleProductPlansSection({product, plans, showLabel = true, sel
);
}
+function getChangePlanClassNames({cookiesDisabled, site}) {
+ let className = 'gh-portal-plans-container is-change-plan hide-checkbox';
+ if (cookiesDisabled) {
+ className += ' disabled';
+ }
+
+ if (hasMultipleProductsFeature({site})) {
+ className += ' has-multiple-products';
+ }
+ return className;
+}
+
+function ChangePlanOptions({plans, selectedPlan, onPlanSelect, changePlan}) {
+ addDiscountToPlans(plans);
+
+ return plans.map(({name, currency_symbol: currencySymbol, amount, description, interval, id}) => {
+ const price = amount / 100;
+ const isChecked = selectedPlan === id;
+ let displayName = interval === 'month' ? 'Monthly' : 'Yearly';
+
+ let planClass = (isChecked ? 'gh-portal-plan-section checked' : 'gh-portal-plan-section');
+ planClass += ' gh-portal-change-plan-section';
+ const planNameClass = 'gh-portal-plan-name no-description';
+ const featureClass = 'gh-portal-plan-featurewrapper';
+
+ return (
+
onPlanSelect(e, id)}>
+
{displayName}
+
+
+ {(changePlan && selectedPlan === id ? Current plan : '')}
+
+
+ );
+ });
+}
+
+export function ChangeProductPlansSection({product, plans, selectedPlan, onPlanSelect, changePlan = false}) {
+ const {site} = useContext(AppContext);
+ if (!product || hasOnlyFreePlan({plans})) {
+ return null;
+ }
+
+ const cookiesDisabled = isCookiesDisabled();
+ /**Don't allow plans selection if cookies are disabled */
+ if (cookiesDisabled) {
+ onPlanSelect = () => {};
+ }
+ const className = getChangePlanClassNames({cookiesDisabled, site});
+
+ return (
+
+ );
+}
+
function PlansSection({plans, showLabel = true, selectedPlan, onPlanSelect, changePlan = false}) {
const {site} = useContext(AppContext);
if (hasOnlyFreePlan({plans})) {
diff --git a/ghost/portal/src/components/common/ProductsSection.js b/ghost/portal/src/components/common/ProductsSection.js
index f65ded20b9..7ebd97ee55 100644
--- a/ghost/portal/src/components/common/ProductsSection.js
+++ b/ghost/portal/src/components/common/ProductsSection.js
@@ -1,8 +1,9 @@
import React, {useContext, useEffect, useState} from 'react';
import Switch from '../common/Switch';
import {ReactComponent as CheckmarkIcon} from '../../images/icons/checkmark.svg';
-import {getSiteProducts, getCurrencySymbol, getPriceString, getStripeAmount, isCookiesDisabled} from '../../utils/helpers';
+import {getSiteProducts, getCurrencySymbol, getPriceString, getStripeAmount, isCookiesDisabled, getPricesFromProducts, getMemberActivePrice} from '../../utils/helpers';
import AppContext from '../../AppContext';
+import {ChangeProductPlansSection} from './PlansSection';
export const ProductsSectionStyles = ({site}) => {
const products = getSiteProducts({site});
@@ -678,4 +679,54 @@ function ProductsSection({onPlanSelect, products, type = null}) {
);
}
+function ChangeProductCard({product, onPlanSelect}) {
+ const {member} = useContext(AppContext);
+ const cardClass = 'gh-portal-product-card';
+ const plans = getPricesFromProducts({products: [product]});
+ const selectedPlan = getMemberActivePrice({member});
+ return (
+
+
+
+
{product.name}
+
{product.description}
+
+
+ {/*
*/}
+
+
+
+
+ );
+}
+
+function ChangeProductCards({products, onPlanSelect}) {
+ return products.map((product) => {
+ if (product.id === 'free') {
+ return null;
+ }
+ return (
+
+ );
+ });
+}
+
+export function ChangeProductSection({products, onPlanSelect}) {
+ return (
+
+
+
+ );
+}
+
export default ProductsSection;
diff --git a/ghost/portal/src/components/pages/AccountPlanPage.js b/ghost/portal/src/components/pages/AccountPlanPage.js
index 3b2cdca613..7484e290ed 100644
--- a/ghost/portal/src/components/pages/AccountPlanPage.js
+++ b/ghost/portal/src/components/pages/AccountPlanPage.js
@@ -192,7 +192,7 @@ const ChangePlanSection = ({plans, selectedPlan, onPlanSelect, onCancelSubscript
showLabel={false}
plans={plans}
selectedPlan={selectedPlan}
- onPlanSelect={(e, priceId) => onPlanSelect(e, priceId)}
+ onPlanSelect={onPlanSelect}
changePlan={true}
/>
@@ -205,13 +205,22 @@ function PlansOrProductSection({showLabel, plans, selectedPlan, onPlanSelect, ch
const {site, member} = useContext(AppContext);
const products = getUpgradeProducts({site, member});
if (hasMultipleProductsFeature({site})) {
- if (hasMultipleProducts({site})) {
+ if (changePlan === true) {
+ return (
+