<div class="registration-upload-passport registration_hide">
    <div class="title">
        <div class="registration-form-title">
            Please upload a photo of your passport photo page
        </div>
    </div>
    <div class="sub-title">
        <div class="registration-form-sub-title">
            This should be a JPEG format and no larger than 1.5MB file size. Please ensure that the scan has no reflections and that all information is clearly readable.
        </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-upload-passport__image-container">
        <img data-allowedSize="5" data-placeholderImage="/assets/example-content/passport.svg" alt="registration passport" class="img" src="/assets/example-content/passport.svg" id="registration-upload-passport__img" loading="lazy" />
    </div>

    <div class="cta">
        <div class="registration-upload-passport__upload-passport-photo">
            <a href="/" class="cta cta--r-primary ">
                <p>UPLOAD FROM FILES</p>
            </a>

        </div>
        <div class="registration-upload-passport__take-passport-photo-click" data-take-photo="Take photo" data-take-photo-error="Your devices camera is not supported. Please upload a picture of your passport.">
            <a href="/" class="cta cta--r-secondary ">
                <p>TAKE PHOTO</p>
            </a>

        </div>
    </div>
</div>

No notes defined.

{
  "title": {
    "copy": "Please upload a photo of your passport photo page"
  },
  "sub-title": {
    "copy": "This should be a JPEG format and no larger than 1.5MB file size. Please ensure that the scan has no reflections and that all information is clearly readable."
  },
  "take-photo": {
    "copy": "Take photo"
  },
  "take-photo-error": {
    "copy": "Your devices camera is not supported. Please upload a picture of your passport."
  },
  "btn-1": {
    "copy": "TAKE PHOTO"
  },
  "btn-2": {
    "copy": "UPLOAD FROM FILES"
  }
}
  • Content:
    /* eslint-disable operator-linebreak */
    /* eslint-disable compat/compat */
    import { base64Obj, camera, fileUpload } from '../../camera';
    import {
      hideServerError,
      showServerError,
    } from '../../registration-server-error/registration-server-error';
    import {
      POST,
      passportUploadPayload,
      passportUploadPath,
      getAuth,
      GET,
      imagepath,
    } from '../../service';
    import {
      BACKCLICKED,
      NEWPASSPORT,
      currentPage,
      hideStep,
      nevigateToNext,
      onComponentVisible,
      showStep,
    } from '../../registrationUtility';
    
    export default (uploadPassport, passportDetails) => {
      const [
        previewElement,
        uploadFileBtn,
        takePhotoBtn,
      ] = uploadPassport.querySelectorAll(
        '.img, .registration-upload-passport__upload-passport-photo .cta--r-primary, .registration-upload-passport__take-passport-photo-click .cta--r-secondary'
      );
      let controller = new AbortController();
    
      const uploadPhoto = async data => {
        const { base64, type } = base64Obj(data);
        const auth = getAuth();
        const res = await POST(passportUploadPath, {
          ...passportUploadPayload,
          JuniorFancode: !!uploadFileBtn.getAttribute('data-fan'),
          FanCode: uploadFileBtn.getAttribute('data-fan')
            ? uploadFileBtn.getAttribute('data-fan')
            : getAuth().fanCode,
          ContentLength: base64.length,
          ContentType: type,
          FileName: `${auth.fanCode}.${type.split('/')[1]}`,
          ImageUploadPassport: base64,
        });
    
        if (res.success && res.photoUploaded) {
          nevigateToNext(uploadPassport);
          passportDetails.querySelector('.passport img').setAttribute('src', data);
        } else {
          showServerError(uploadPassport, res.error);
        }
      };
    
      onComponentVisible(uploadPassport, async () => {
        controller.abort('Removing previous event listeners');
        controller = new AbortController();
        hideServerError(uploadPassport);
        showStep('03');
        if (
          uploadPassport.classList.contains('registration-upload-passport-cloned')
        ) {
          hideStep();
        }
        currentPage.page = uploadPassport;
    
        previewElement.setAttribute(
          'src',
          previewElement.getAttribute('data-placeholderImage')
        );
    
        const uploadPhotoHandler = (event, prevEle, upldPas) => {
          event.preventDefault();
          fileUpload(prevEle, uploadPhoto, upldPas);
        };
    
        takePhotoBtn.addEventListener(
          'click',
          event => {
            let parentElement;
            const { tagName } = event.target;
    
            if (tagName === 'P') {
              parentElement = event.target.parentElement.parentElement;
            } else {
              parentElement = event.target.parentElement;
            }
            event.preventDefault();
            hideServerError(uploadPassport);
            camera(
              previewElement,
              uploadPhoto,
              uploadPassport,
              parentElement.attributes[2]
                ? parentElement.attributes[2].value
                : 'Your devices camera is not supported. Please upload a picture of your passport.',
              parentElement.attributes[1]
                ? parentElement.attributes[1].value
                : 'Take photo'
            );
          },
          { signal: controller.signal }
        );
    
        uploadFileBtn.addEventListener(
          'click',
          event => uploadPhotoHandler(event, previewElement, uploadPassport),
          { signal: controller.signal }
        );
    
        if (sessionStorage.getItem(NEWPASSPORT)) {
          sessionStorage.removeItem(NEWPASSPORT);
        } else {
          const imageResponse = await GET(
            imagepath(
              uploadFileBtn.getAttribute('data-fan')
                ? uploadFileBtn.getAttribute('data-fan')
                : getAuth().fanCode,
              'Passport'
            )
          );
    
          if (imageResponse.success) {
            passportDetails
              .querySelector('.passport img')
              .setAttribute('src', imageResponse.src);
            nevigateToNext(uploadPassport);
          }
        }
        sessionStorage.removeItem(NEWPASSPORT);
        sessionStorage.removeItem(BACKCLICKED);
      });
    };
    
  • URL: /components/raw/registration-upload-passport/registration-upload-passport.js
  • Filesystem Path: src/library/modules/registration/registration-self/registration-upload-passport/registration-upload-passport.js
  • Size: 4 KB
  • Content:
    .registration-upload-passport-cloned,
    .registration-upload-passport {
      $cta-container-mt: 32px;
      $cta-gap: 16px;
      $body-mt: 32px;
    
      &__image-container {
        margin-top: $body-mt;
    
        img {
          margin: auto;
        }
      }
    
      & > .cta {
        margin-top: $cta-container-mt;
    
        .cta--r-secondary,
        .cta--r-primary {
          min-height: 44px;
          font-size: 16px;
        }
    
        div:not(:first-child) {
          margin-top: $cta-gap;
        }
      }
    
      @media screen and (max-width: $mq-medium) {
        &__take-passport-photo-click {
          display: none;
        }
      }
    }
    
  • URL: /components/raw/registration-upload-passport/registration-upload-passport.scss
  • Filesystem Path: src/library/modules/registration/registration-self/registration-upload-passport/registration-upload-passport.scss
  • Size: 554 Bytes
{{!-- adding  registration_hide--}}
<div class="registration-upload-passport registration_hide">
    <div class="title">
        {{render '@registration-form-title' title}}
    </div>
    <div class="sub-title">
        {{render '@registration-form-sub-title' sub-title}}
    </div>
   {{!-- adding error --}}
    {{render '@registration-server-error'}}

    <div class="registration-upload-passport__image-container">
        <img data-allowedSize="5" data-placeholderImage="/assets/example-content/passport.svg" alt="registration passport" class="img"
            src="/assets/example-content/passport.svg" id="registration-upload-passport__img" loading="lazy"/>
    </div>

    <div class="cta">
        <div class="registration-upload-passport__upload-passport-photo">
            {{render '@cta--r-primary' btn-2 merge="true"}}
        </div>
        <div class="registration-upload-passport__take-passport-photo-click" data-take-photo= "Take photo" data-take-photo-error= "Your devices camera is not supported. Please upload a picture of your passport." >
            {{render '@cta--r-secondary' btn-1 merge="true"}}
        </div>
    </div>
</div>