<div class="registration-junior-last-step registration_hide">
    <div class="registration-junior-last-step__title">
        <div class="registration-form-title">
            Last step...
        </div>
    </div>
    <div class="registration-junior-last-step__sub-title">
        <div class="registration-form-sub-title">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
        </div>
    </div>
    <div class="registration-error registration-server-error registration_hide" role="alert">
        <span class="registration-error-message">sitecore api error</span>
    </div>
    <div class="registration-junior-last-step__checkbox">
        <label class="checkbox checkbox--secondary">
            <input type="checkbox" name="faPolicy1">

            <span class="label">I agree to the Terms and Conditions and Privacy Policy</span>

            <span class="checkmark-container">
                <span class="checkmark"></span>
            </span>
        </label>
    </div>

    <div class="registration-junior-last-step__next">
        <a href="/" class="cta cta--r-disabled ">
            <p>NEXT</p>
        </a>

    </div>
</div>

No notes defined.

{
  "title": {
    "copy": "Last step..."
  },
  "sub-title": {
    "copy": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
  },
  "privacy-policy": {
    "copy": "I agree to the Terms and Conditions and Privacy Policy",
    "name": "faPolicy1"
  },
  "next": {
    "copy": "NEXT"
  }
}
  • Content:
    /* eslint-disable no-param-reassign */
    /* eslint-disable compat/compat */
    import { hideClass } from '../../registration-error/registration-error';
    import {
      cloneElement,
      currentPage,
      localdate,
      newJunior,
      onComponentVisible,
      showBackBtn,
      showStep,
    } from '../../registrationUtility';
    import {
      showServerError,
      hideServerError,
    } from '../../registration-server-error/registration-server-error';
    import { juniorMembershipPath, POST } from '../../service';
    import Validator from '../../validation';
    
    export default (currentElement, addingJunior, addRelation, juniorDetails) => {
      const clearForm = () => {
        addRelation.querySelectorAll('input').forEach(element => {
          element.checked = false;
        });
    
        juniorDetails.querySelectorAll('input').forEach(element => {
          element.value = '';
        });
      };
      const nextBtnClickHandler = async (event, nextBtn) => {
        event.preventDefault();
        const [
          firstNameElement,
          surNameElement,
          dateOfBirthElement,
        ] = juniorDetails.querySelectorAll(
          '.registration-junior-details__first-name input, .registration-junior-details__surname input, .DateOfBirth input'
        );
    
        if (nextBtn.classList.contains('cta--r-primary')) {
          const [inContainer, infoTemplate] = addingJunior.querySelectorAll(
            '.detail, .info-template'
          );
          const response = await POST(juniorMembershipPath, {
            ...newJunior,
            FirstName: firstNameElement.value,
            LastName: surNameElement.value,
            DateOfBirth: dateOfBirthElement.value,
          });
    
          if (response.success) {
            const newUser = cloneElement(infoTemplate);
    
            newUser.classList.add('info');
            const [infoKey, infoValue] = newUser.querySelectorAll(
              '.info__key, .info__value'
            );
            const { fullName, dob } = response.junior;
    
            infoKey.innerText = `${fullName}`;
    
            if (dob) {
              infoValue.innerText = `${infoValue.innerText} ${localdate(
                new Date(dob)
              )}`;
            }
            inContainer.appendChild(newUser);
            clearForm();
            currentElement.classList.add(hideClass);
            addingJunior.classList.remove(hideClass);
          } else {
            showServerError(currentElement, response.error);
          }
        }
      };
    
      const checkboxChangeHandler = (event, btn) => {
        const { checked } = event.target;
    
        Validator.swaapBtn(btn, checked);
      };
    
      let controller = new AbortController();
    
      onComponentVisible(currentElement, () => {
        controller.abort('Removing previous event listeners');
        controller = new AbortController();
        showStep('03');
        showBackBtn();
        hideServerError(currentElement);
        currentPage.page = currentElement;
    
        const [checkbox, btn] = currentElement.querySelectorAll(
          '.registration-junior-last-step__checkbox input, .registration-junior-last-step__next a'
        );
    
        btn.addEventListener('click', e => nextBtnClickHandler(e, btn), {
          signal: controller.signal,
        });
        checkbox.addEventListener(
          'change',
          event => checkboxChangeHandler(event, btn),
          { signal: controller.signal }
        );
      });
    };
    
  • URL: /components/raw/registration-junior-last-step/registration-junior-last-step.js
  • Filesystem Path: src/library/modules/registration/registration-self/registration-junior-last-step/registration-junior-last-step.js
  • Size: 3.1 KB
  • Content:
    .registration-junior-last-step {
      $cta-gap: 16px;
      $body-mt: 24px;
      $cta-container-mt: 40px;
    
      .registration-junior-last-step__checkbox {
        margin-top: $body-mt;
      }
    
      &__next {
        margin-top: $cta-container-mt;
      }
    }
    
  • URL: /components/raw/registration-junior-last-step/registration-junior-last-step.scss
  • Filesystem Path: src/library/modules/registration/registration-self/registration-junior-last-step/registration-junior-last-step.scss
  • Size: 226 Bytes
<div class="registration-junior-last-step registration_hide">
  <div class="registration-junior-last-step__title">
    {{render '@registration-form-title' title}}
  </div>
  <div class="registration-junior-last-step__sub-title">
    {{render '@registration-form-sub-title' sub-title}}
  </div>
  {{render '@registration-server-error'}}
  <div class="registration-junior-last-step__checkbox">
    {{render '@checkbox--secondary' privacy-policy merge="true"}}
  </div>

  <div class="registration-junior-last-step__next">
    {{render '@cta--r-disabled' next merge="true"}}
  </div>
</div>