diff --git a/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-m-a-switch.js b/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-m-a-switch.js index 1878a0c674..faa30804b8 100644 --- a/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-m-a-switch.js +++ b/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-m-a-switch.js @@ -7,14 +7,16 @@ export function toggleMonthlyAnnualSwitching( const containerEl = document.querySelector( '[data-ol-plans-v2-m-a-switch-container]' ) - const checkbox = containerEl.querySelector('input[type="checkbox"]') + if (containerEl) { + const checkbox = containerEl.querySelector('input[type="checkbox"]') - containerEl.classList.toggle('disabled', view === 'group') + containerEl.classList.toggle('disabled', view === 'group') - checkbox.disabled = view === 'group' - checkbox.checked = currentMonthlyAnnualSwitchValue === 'monthly' + checkbox.disabled = view === 'group' + checkbox.checked = currentMonthlyAnnualSwitchValue === 'monthly' - switchMonthlyAnnual(currentMonthlyAnnualSwitchValue) + switchMonthlyAnnual(currentMonthlyAnnualSwitchValue) + } } export function switchMonthlyAnnual(currentMonthlyAnnualSwitchValue) { diff --git a/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-main.js b/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-main.js index 0d68a3a06e..0dbb0aedda 100644 --- a/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-main.js +++ b/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-main.js @@ -117,14 +117,24 @@ function selectTab(viewTab) { el.hidden = el.getAttribute('data-ol-plans-v2-view') !== viewTab }) - document.querySelector('[data-ol-plans-v2-m-a-tooltip]').hidden = - viewTab === 'group' - document.querySelector('[data-ol-plans-v2-license-picker-container]').hidden = - viewTab !== 'group' + const tooltipEl = document.querySelector('[data-ol-plans-v2-m-a-tooltip]') + if (tooltipEl) { + tooltipEl.hidden = viewTab === 'group' + } - document - .querySelector('[data-ol-plans-v2-m-a-switch-container]') - .setAttribute('data-ol-current-view', viewTab) + const licensePickerEl = document.querySelector( + '[data-ol-plans-v2-license-picker-container]' + ) + if (licensePickerEl) { + licensePickerEl.hidden = viewTab !== 'group' + } + + const monthlyAnnualSwitch = document.querySelector( + '[data-ol-plans-v2-m-a-switch-container]' + ) + if (monthlyAnnualSwitch) { + monthlyAnnualSwitch.setAttribute('data-ol-current-view', viewTab) + } if (viewTab === 'group') { updateMainGroupPlanPricing() @@ -208,8 +218,9 @@ function setUpGroupPlanPricingChange() { function toggleUniversityInfo(viewTab) { const el = document.querySelector('[data-ol-plans-university-info-container]') - - el.hidden = viewTab !== 'student' + if (el) { + el.hidden = viewTab !== 'student' + } } // This is the old scheme for hashing redirection