plans-v2-subscription-button.js 1010 B

1234567891011121314151617181920212223242526272829303132
  1. import { updateGroupModalPlanPricing } from '../../../../features/plans/group-plan-modal'
  2. function showGroupPlanModal(el) {
  3. const plan = el.getAttribute('data-ol-start-new-subscription')
  4. // plan is either `group_collaborator` or `group_professional`
  5. // we want to get the suffix (collaborator or professional)
  6. const groupPlan = plan.split('_')[1]
  7. const groupModalRadioInputEl = document.querySelector(
  8. `[data-ol-group-plan-code="${groupPlan}"]`
  9. )
  10. groupModalRadioInputEl.checked = true
  11. updateGroupModalPlanPricing()
  12. const modalEl = $('[data-ol-group-plan-modal]')
  13. modalEl.modal()
  14. }
  15. export function setUpGroupSubscriptionButtonAction() {
  16. document.querySelectorAll('[data-ol-start-new-subscription]').forEach(el => {
  17. const plan = el.getAttribute('data-ol-start-new-subscription')
  18. if (plan === 'group_collaborator' || plan === 'group_professional') {
  19. el.addEventListener('click', e => {
  20. e.preventDefault()
  21. showGroupPlanModal(el)
  22. })
  23. }
  24. })
  25. }