Changed checked value to use portal plans on toggle (#18708)

no issue

- this adds a bit more logic to ensure the portal plans remain consistent with the tier's visibility in the portal preview.
---

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 74fd5c4</samp>

Refactored the `Free` tier checkbox in the portal signup options
component to use the `portalPlans` array. This improves the consistency
and reliability of the portal plans settings.
This commit is contained in:
Ronald Langeveld 2023-10-20 17:02:08 +07:00 committed by Jono Mingard
parent 375be17737
commit a08e5ef324

View File

@ -66,13 +66,22 @@ const SignupOptions: React.FC<{
localTiers.forEach((tier) => {
if (tier.name === 'Free') {
tiersCheckboxes.push({
checked: tier.visibility === 'public',
checked: (portalPlans.includes('free')),
disabled: isDisabled,
label: 'Free',
value: 'free',
onChange: (checked) => {
if (portalPlans.includes('free') && !checked) {
portalPlans.splice(portalPlans.indexOf('free'), 1);
}
if (!portalPlans.includes('free') && checked) {
portalPlans.push('free');
}
updateSetting('portal_plans', JSON.stringify(portalPlans));
updateTier({...tier, visibility: checked ? 'public' : 'none'});
togglePlan('free');
}
});
}