From 7aa460d66b58c80e250db8591b73071774a94612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ca=C5=82ka?= <25438601+rafaucau@users.noreply.github.com> Date: Sat, 23 Nov 2024 11:59:31 +0100 Subject: [PATCH] fix(optional-policies): hide Policies section in user profile when no optional policies exist (#60) * fix(optional-policies): hide Policies section in user profile when no optional policies exist * refactor(optional-policies): rename `policies` variable to `optionalPolicies` for better clarity --- js/src/forum/components/addManagePoliciesOption.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/src/forum/components/addManagePoliciesOption.js b/js/src/forum/components/addManagePoliciesOption.js index ed3b221..348547e 100644 --- a/js/src/forum/components/addManagePoliciesOption.js +++ b/js/src/forum/components/addManagePoliciesOption.js @@ -16,14 +16,17 @@ async function updatePolicy(policy, value) { export default function () { extend(SettingsPage.prototype, 'settingsItems', function (items) { - const policies = app.store.all('fof-terms-policies').filter((policy) => policy.optional()); + const optionalPolicies = app.store.all('fof-terms-policies').filter((policy) => policy.optional()); + if (!optionalPolicies.length) { + return; + } let policyState = app.session.user.fofTermsPoliciesState(); items.add( 'policies',
- {policies.map((policy) => { + {optionalPolicies.map((policy) => { const { is_accepted } = policyState[policy.id()]; return (