2022-05-19 07:57:36 -04:00
|
|
|
import { updateGroupModalPlanPricing } from '../../../../features/plans/group-plan-modal'
|
|
|
|
|
2022-06-22 08:22:11 -04:00
|
|
|
function showGroupPlanModal(el) {
|
|
|
|
const plan = el.getAttribute('data-ol-start-new-subscription')
|
|
|
|
|
|
|
|
// plan is either `group_collaborator` or `group_professional`
|
|
|
|
// we want to get the suffix (collaborator or professional)
|
2022-05-12 07:38:02 -04:00
|
|
|
const groupPlan = plan.split('_')[1]
|
|
|
|
|
|
|
|
const groupModalRadioInputEl = document.querySelector(
|
|
|
|
`[data-ol-group-plan-code="${groupPlan}"]`
|
|
|
|
)
|
|
|
|
|
2022-05-19 07:57:36 -04:00
|
|
|
groupModalRadioInputEl.checked = true
|
|
|
|
updateGroupModalPlanPricing()
|
2022-05-12 07:38:02 -04:00
|
|
|
|
|
|
|
const modalEl = $('[data-ol-group-plan-modal]')
|
|
|
|
modalEl.modal()
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setUpGroupSubscriptionButtonAction() {
|
|
|
|
document.querySelectorAll('[data-ol-start-new-subscription]').forEach(el => {
|
|
|
|
const plan = el.getAttribute('data-ol-start-new-subscription')
|
|
|
|
|
|
|
|
if (plan === 'group_collaborator' || plan === 'group_professional') {
|
|
|
|
el.addEventListener('click', e => {
|
|
|
|
e.preventDefault()
|
|
|
|
showGroupPlanModal(el)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|