mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Added static dropdown for selecting default price plan
refs GRO-141
This commit is contained in:
parent
36294c6482
commit
7026b28e17
1 changed files with 37 additions and 23 deletions
|
@ -1,5 +1,6 @@
|
||||||
import React, {useCallback, useEffect, useMemo} from 'react';
|
import React, {useCallback, useEffect, useMemo} from 'react';
|
||||||
import {CheckboxGroup, CheckboxProps, Form, HtmlField, Toggle} from '@tryghost/admin-x-design-system';
|
import useFeatureFlag from '../../../../hooks/useFeatureFlag';
|
||||||
|
import {CheckboxGroup, CheckboxProps, Form, HtmlField, Select, SelectOption, Toggle} from '@tryghost/admin-x-design-system';
|
||||||
import {Setting, SettingValue, checkStripeEnabled, getSettingValues} from '@tryghost/admin-x-framework/api/settings';
|
import {Setting, SettingValue, checkStripeEnabled, getSettingValues} from '@tryghost/admin-x-framework/api/settings';
|
||||||
import {Tier, getPaidActiveTiers} from '@tryghost/admin-x-framework/api/tiers';
|
import {Tier, getPaidActiveTiers} from '@tryghost/admin-x-framework/api/tiers';
|
||||||
import {useGlobalData} from '../../../providers/GlobalDataProvider';
|
import {useGlobalData} from '../../../providers/GlobalDataProvider';
|
||||||
|
@ -85,6 +86,14 @@ const SignupOptions: React.FC<{
|
||||||
}
|
}
|
||||||
|
|
||||||
const paidActiveTiersResult = getPaidActiveTiers(localTiers) || [];
|
const paidActiveTiersResult = getPaidActiveTiers(localTiers) || [];
|
||||||
|
const hasPortalImprovements = useFeatureFlag('portalImprovements');
|
||||||
|
|
||||||
|
// TODO: Hook up with actual values and then delete this
|
||||||
|
const selectOptions: SelectOption[] = [
|
||||||
|
{value: 'default-yearly', label: 'Yearly'},
|
||||||
|
{value: 'default-monthly', label: 'Monthly'}
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
if (paidActiveTiersResult.length > 0 && isStripeEnabled) {
|
if (paidActiveTiersResult.length > 0 && isStripeEnabled) {
|
||||||
paidActiveTiersResult.forEach((tier) => {
|
paidActiveTiersResult.forEach((tier) => {
|
||||||
|
@ -112,29 +121,34 @@ const SignupOptions: React.FC<{
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{isStripeEnabled && localTiers.some(tier => tier.visibility === 'public') && (
|
{isStripeEnabled && localTiers.some(tier => tier.visibility === 'public') && (
|
||||||
<CheckboxGroup
|
<>
|
||||||
checkboxes={[
|
<CheckboxGroup
|
||||||
{
|
checkboxes={[
|
||||||
checked: portalPlans.includes('monthly'),
|
{
|
||||||
disabled: isDisabled,
|
checked: portalPlans.includes('monthly'),
|
||||||
label: 'Monthly',
|
disabled: isDisabled,
|
||||||
value: 'monthly',
|
label: 'Monthly',
|
||||||
onChange: () => {
|
value: 'monthly',
|
||||||
togglePlan('monthly');
|
onChange: () => {
|
||||||
|
togglePlan('monthly');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
checked: portalPlans.includes('yearly'),
|
||||||
|
disabled: isDisabled,
|
||||||
|
label: 'Yearly',
|
||||||
|
value: 'yearly',
|
||||||
|
onChange: () => {
|
||||||
|
togglePlan('yearly');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
]}
|
||||||
{
|
title='Prices available at signup'
|
||||||
checked: portalPlans.includes('yearly'),
|
/>
|
||||||
disabled: isDisabled,
|
{hasPortalImprovements && <Select options={selectOptions} selectedOption={selectOptions.find(option => option.value === 'default-yearly')} title='Price shown by default' onSelect={(value) => {
|
||||||
label: 'Yearly',
|
alert(value);
|
||||||
value: 'yearly',
|
}} />}
|
||||||
onChange: () => {
|
</>
|
||||||
togglePlan('yearly');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
title='Prices available at signup'
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<HtmlField
|
<HtmlField
|
||||||
|
|
Loading…
Add table
Reference in a new issue