From a08e5ef3247fecc4c8a132d1232282a5f226ef02 Mon Sep 17 00:00:00 2001 From: Ronald Langeveld Date: Fri, 20 Oct 2023 17:02:08 +0700 Subject: [PATCH] Changed checked value to use portal plans on toggle (#18708) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue - this adds a bit more logic to ensure the portal plans remain consistent with the tier's visibility in the portal preview. --- ### 🤖 Generated by Copilot at 74fd5c4 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. --- .../settings/membership/portal/SignupOptions.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/admin-x-settings/src/components/settings/membership/portal/SignupOptions.tsx b/apps/admin-x-settings/src/components/settings/membership/portal/SignupOptions.tsx index 0391add212..e13bd61939 100644 --- a/apps/admin-x-settings/src/components/settings/membership/portal/SignupOptions.tsx +++ b/apps/admin-x-settings/src/components/settings/membership/portal/SignupOptions.tsx @@ -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'); } }); }