<div class="registration-passport-details registration_hide">
<div class="title">
<div class="registration-form-title">
Passport uploaded successfully
</div>
</div>
<div class="sub-title">
<div class="registration-form-sub-title">
Please enter your passport information below
</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="passport">
<img src="/assets/example-content/rectangleGuideline.svg" alt="rectangleGuideline">
</div>
<div class="form-fields">
<div class="place-of-birth">
<div class="registration-text-input-container">
<label class="registration-text-input-container__label" for=placeOfBirth>
Place of birth
</label>
<input class="registration-text-input-container__text-input" data-maxlength="50" type="text" name="placeOfBirth" id="placeOfBirth" autocomplete="address-level1" placeholder="Place of birth (City or town)" />
<div class="registration-error registration_hide" role="alert">
<span class="registration-error-message registration_hide" id="invalid-b2c-contact-number">invalid-b2c-contact-number</span>
<span class="registration-error-message registration_hide" id="invalid-input-required">Requird</span>
<span class="registration-error-message registration_hide" id="invalid-input-length">invalid-length</span>
<span class="registration-error-message registration_hide" id="invalid-input-alphabets-only">alphabets-only</span>
<span class="registration-error-message registration_hide" id="invalid-input-alphanumeric">alpha numeric</span>
<span class="registration-error-message registration_hide" id="invalid-input-underflow">A junior account cannot be 16 years old or above</span>
<span class="registration-error-message registration_hide" id="invalid-input-overflow">A junior account cannot be 16 years old or above</span>
<span class="registration-error-message registration_hide" id="invalid-character-length">length-should-be-9characters</span>
</div>
</div>
</div>
<div class="passport-number">
<div class="registration-text-input-container">
<label class="registration-text-input-container__label" for=passportNumber>
Passport number
</label>
<input class="registration-text-input-container__text-input" type="text" name="passportNumber" id="passportNumber" autocomplete="off" placeholder="Passport number" />
<div class="registration-error registration_hide" role="alert">
<span class="registration-error-message registration_hide" id="invalid-b2c-contact-number">invalid-b2c-contact-number</span>
<span class="registration-error-message registration_hide" id="invalid-input-required">Requird</span>
<span class="registration-error-message registration_hide" id="invalid-input-length">invalid-length</span>
<span class="registration-error-message registration_hide" id="invalid-input-alphabets-only">alphabets-only</span>
<span class="registration-error-message registration_hide" id="invalid-input-alphanumeric">alpha numeric</span>
<span class="registration-error-message registration_hide" id="invalid-input-underflow">A junior account cannot be 16 years old or above</span>
<span class="registration-error-message registration_hide" id="invalid-input-overflow">A junior account cannot be 16 years old or above</span>
<span class="registration-error-message registration_hide" id="invalid-character-length">length-should-be-9characters</span>
</div>
</div>
</div>
<div class="passport-expiry untouched-element">
<div class="registration-text-input-container">
<label class="registration-text-input-container__label" for=passportExpiry>
Passport Expiry
</label>
<input class="registration-text-input-container__text-input" type="date" data-max='2024-12-31' data-min='2010-12-10' max='9999-12-31' name="passportExpiry" id="passportExpiry" autocomplete="bday" placeholder="Passport Expiry" />
<div class="registration-error registration_hide" role="alert">
<span class="registration-error-message registration_hide" id="invalid-b2c-contact-number">invalid-b2c-contact-number</span>
<span class="registration-error-message registration_hide" id="invalid-input-required">Requird</span>
<span class="registration-error-message registration_hide" id="invalid-input-length">invalid-length</span>
<span class="registration-error-message registration_hide" id="invalid-input-alphabets-only">alphabets-only</span>
<span class="registration-error-message registration_hide" id="invalid-input-alphanumeric">alpha numeric</span>
<span class="registration-error-message registration_hide" id="invalid-input-underflow">A junior account cannot be 16 years old or above</span>
<span class="registration-error-message registration_hide" id="invalid-input-overflow">A junior account cannot be 16 years old or above</span>
<span class="registration-error-message registration_hide" id="invalid-character-length">length-should-be-9characters</span>
</div>
</div>
</div>
<div class="nationality untouched-element">
<div class="registration-custom-select registration-text-input-container">
<label class="registration-text-input-container__label registration-custom-select__label" for="nationality">
Nationality
</label>
<select name=nationality id=nationality aria-label=Nationality>
<option disabled selected value="select">Nationality</option>
<option value="Pakistan">Saab</option>
<option value="Srilanka">Mercedes</option>
<option value="Nepal">Audi</option>
</select>
<div class="registration-error registration_hide" role="alert">
<span class="registration-error-message registration_hide" id="invalid-b2c-contact-number">invalid-b2c-contact-number</span>
<span class="registration-error-message registration_hide" id="invalid-input-required">Requird</span>
<span class="registration-error-message registration_hide" id="invalid-input-length">invalid-length</span>
<span class="registration-error-message registration_hide" id="invalid-input-alphabets-only">alphabets-only</span>
<span class="registration-error-message registration_hide" id="invalid-input-alphanumeric">alpha numeric</span>
<span class="registration-error-message registration_hide" id="invalid-input-underflow">A junior account cannot be 16 years old or above</span>
<span class="registration-error-message registration_hide" id="invalid-input-overflow">A junior account cannot be 16 years old or above</span>
<span class="registration-error-message registration_hide" id="invalid-character-length">length-should-be-9characters</span>
</div>
</div>
</div>
<div class="cta">
<div class="next-to-step-5">
<a href="/" class="cta cta--r-disabled " id="nextBtn">
<p>NEXT</p>
</a>
</div>
<div class="next-to-step-3">
<a href="/" class="cta cta--r-secondary " id="uploadNewPhoto">
<p>UPLOAD NEW PHOTO (OPTIONAL)</p>
</a>
</div>
</div>
</div>
</div>
No notes defined.
{
"title": {
"copy": "Passport uploaded successfully"
},
"sub-title": {
"copy": "Please enter your passport information below"
},
"placeOfBirth": {
"id": "placeOfBirth",
"name": "placeOfBirth",
"ariaLabel": "Place of birth (City or town)",
"type": "text",
"placeholder": "Place of birth (City or town)",
"label": "Place of birth",
"autocomplete": "address-level1",
"maxlength": 50
},
"passportNumber": {
"id": "passportNumber",
"name": "passportNumber",
"ariaLabel": "Passport number",
"type": "text",
"placeholder": "Passport number",
"label": "Passport number",
"autocomplete": "off"
},
"passportExpiry": {
"id": "passportExpiry",
"name": "passportExpiry",
"ariaLabel": "Passport Expiry",
"type": "date",
"placeholder": "Passport Expiry",
"label": "Passport Expiry",
"autocomplete": "bday",
"max": "2024-12-31",
"min": "2010-12-10"
},
"nationality": {
"copy": "Nationality",
"name": "nationality",
"ariaLabel": "Nationality"
},
"nextBtn": {
"copy": "NEXT",
"id": "nextBtn"
},
"uploadNewPhoto": {
"copy": "UPLOAD NEW PHOTO (OPTIONAL)",
"id": "uploadNewPhoto"
}
}
/* eslint-disable operator-linebreak */
/* eslint-disable compat/compat */
import {
hideAllError,
showError,
} from '../../registration-error/registration-error';
import {
hideServerError,
showServerError,
} from '../../registration-server-error/registration-server-error';
import {
NEWPASSPORT,
currentPage,
hideStep,
nevigateToNext,
nevigateToPrevious,
onComponentVisible,
showStep,
} from '../../registrationUtility';
import {
GET,
POST,
getAuth,
getPassportDetailsPath,
passportDetailPath,
passportDetailsPayload,
} from '../../service';
import Validator from '../../validation';
export default currentElement => {
let controller = new AbortController();
const untouched = 'untouched-element';
const nextElementClickHandler = async (
event,
nextBtn,
placeOfBirthElement,
passportNumberhElement,
passportExpiryElement,
nationalityElement
) => {
event.preventDefault();
if (nextBtn.classList.contains('cta--r-primary')) {
const res = await POST(passportDetailPath, {
...passportDetailsPayload,
JuniorFancode: !!nextBtn.getAttribute('data-fan'),
FanCode: nextBtn.getAttribute('data-fan')
? nextBtn.getAttribute('data-fan')
: getAuth().fanCode,
PlaceOfBirth: placeOfBirthElement.value,
PassportExpiry: passportExpiryElement.value,
PassportNo: passportNumberhElement.value,
Nationality: nationalityElement.value,
});
if (!res.success) {
showServerError(currentElement, res.error);
} else {
nevigateToNext(currentElement);
}
}
};
const uoploadNewPhotoElementClickHandler = event => {
event.preventDefault();
sessionStorage.setItem(NEWPASSPORT, true);
nevigateToPrevious(currentElement);
};
const keydownEventHandler = event => {
const { key, target } = event;
const { id } = target;
switch (id) {
case 'placeOfBirth':
if (!Validator.isAlphabets(key, [' '])) {
event.preventDefault();
}
break;
case 'passportNumber':
if (!Validator.isAlphaNumeric(event.key)) {
event.preventDefault();
}
break;
default:
break;
}
};
const isplaceOfBirthValid = (value, maxlength) =>
Validator.validate([
() => Validator.required(value),
() => Validator.alphabetsOnly(value, ' '),
() => Validator.between(value, 1, maxlength),
]);
const isPassportNumberValid = value =>
Validator.validate([
() => Validator.required(value),
() => Validator.alphaNumeric(value),
() => Validator.between(value, 6, 10),
]);
const isPassportExpiryValid = (value, minDate, maxDate) =>
Validator.validate([
() => Validator.required(value),
() => Validator.dateUnderflow(value, minDate),
() => Validator.dateOverflow(value, maxDate),
]);
const isNationalityValid = value =>
Validator.validate([
() => Validator.required(value === 'select' ? '' : value),
]);
const isFormValid = (
placeOfBirth,
placeOfBirthMaxlen,
passportNumber,
expiryDate,
Nationality,
minDate,
maxDate
) =>
!isplaceOfBirthValid(placeOfBirth, placeOfBirthMaxlen) &&
!isPassportNumberValid(passportNumber) &&
!isPassportExpiryValid(expiryDate, minDate, maxDate) &&
!isNationalityValid(Nationality);
const elementInputHandler = (
nextButton,
placeOfBirth,
passportNumber,
expiryDate,
Nationality
) => {
const isValid = isFormValid(
placeOfBirth.value,
placeOfBirth.dataset.maxlength,
passportNumber.value,
expiryDate.value,
Nationality.value,
expiryDate.dataset.min,
expiryDate.dataset.max
);
Validator.swaapBtn(nextButton, isValid);
};
const togglePlaceholder = (element, boolVal) => {
const parentEle = element.parentElement.parentElement;
if (boolVal) {
parentEle.classList.remove(untouched);
} else {
parentEle.classList.add(untouched);
}
};
const inputPickerFieldHandler = event => {
const { target } = event;
const { value } = target;
togglePlaceholder(target, value && value !== 'select');
};
const passportExpiryFocusHandler = event => {
togglePlaceholder(event.target, true);
};
const elementBlurHandler = event => {
event.preventDefault();
const thisNode = event.target;
const { id, value, dataset } = thisNode;
let errorMessage;
hideAllError(thisNode.parentElement);
switch (id) {
case 'placeOfBirth':
errorMessage = isplaceOfBirthValid(value, thisNode.dataset.maxlength);
break;
case 'passportNumber':
errorMessage = isPassportNumberValid(value);
break;
case 'passportExpiry':
errorMessage = isPassportExpiryValid(value, dataset.min, dataset.max);
// eslint-disable-next-line no-param-reassign
currentElement.querySelector(`#${event.target.id}`).value = value;
togglePlaceholder(thisNode, value);
break;
case 'nationality':
errorMessage = isNationalityValid(value);
break;
default:
break;
}
if (errorMessage) {
showError(thisNode.parentElement, errorMessage);
}
};
onComponentVisible(currentElement, async () => {
const isChildComponent = currentElement.classList.contains(
'registration-passport-details-cloned'
);
currentPage.page = currentElement;
controller.abort('Removing previous event listeners');
controller = new AbortController();
showStep('03');
const [
placeOfBirthElement,
passportNumberhElement,
passportExpiryElement,
nationalityElement,
nextElement,
uoploadNewPhotoElement,
] = currentElement.querySelectorAll(
'#placeOfBirth, #passportNumber, #passportExpiry, #nationality, #nextBtn, #uploadNewPhoto'
);
// fixing the image renderer
const image = currentElement.querySelector('.passport img');
image.setAttribute('src', image.getAttribute('data-img'));
image.addEventListener('load', () => {
placeOfBirthElement.focus();
setTimeout(() => {
image.style.webkitTransform = 'scale(1)';
}, 200);
});
if (isChildComponent) {
hideStep();
const personalDetailRes = await GET(
getPassportDetailsPath(nextElement.getAttribute('data-fan'))
);
if (personalDetailRes.success) {
placeOfBirthElement.value = personalDetailRes.passport.placeOfBirth;
passportNumberhElement.value = personalDetailRes.passport.passportNo;
passportExpiryElement.value = personalDetailRes.passport.passportExpiry;
nationalityElement.value = personalDetailRes.passport.nationality
? personalDetailRes.passport.nationality
: 'select';
}
}
hideServerError(currentElement);
togglePlaceholder(passportExpiryElement, passportExpiryElement.value);
togglePlaceholder(
nationalityElement,
nationalityElement.value && nationalityElement.value !== 'select'
);
Validator.swaapBtn(
nextElement,
isFormValid(
placeOfBirthElement.value,
placeOfBirthElement.dataset.maxlength,
passportNumberhElement.value,
passportExpiryElement.value,
nationalityElement.value,
passportExpiryElement.dataset.min,
passportExpiryElement.dataset.max
)
);
const textFields = [placeOfBirthElement, passportNumberhElement];
const pickerField = [nationalityElement];
const inputElements = [
passportExpiryElement,
...textFields,
...pickerField,
];
passportExpiryElement.addEventListener(
'focus',
passportExpiryFocusHandler,
{
signal: controller.signal,
}
);
inputElements.forEach(element => {
element.addEventListener('blur', elementBlurHandler, {
signal: controller.signal,
});
element.addEventListener(
'input',
() =>
elementInputHandler(
nextElement,
placeOfBirthElement,
passportNumberhElement,
passportExpiryElement,
nationalityElement
),
{
signal: controller.signal,
}
);
});
textFields.forEach(element => {
element.addEventListener('keydown', keydownEventHandler, {
signal: controller.signal,
});
});
pickerField.forEach(element => {
element.addEventListener('input', inputPickerFieldHandler, {
signal: controller.signal,
});
});
nextElement.addEventListener(
'click',
event =>
nextElementClickHandler(
event,
nextElement,
placeOfBirthElement,
passportNumberhElement,
passportExpiryElement,
nationalityElement,
currentElement
),
{
signal: controller.signal,
}
);
uoploadNewPhotoElement.addEventListener(
'click',
uoploadNewPhotoElementClickHandler,
{
signal: controller.signal,
}
);
});
};
.registration-passport-details-cloned,
.registration-passport-details {
$cta-container-mt: 40px;
$cta-gap: 16px;
$body-mt: 32px;
.passport img {
margin: auto;
}
& > .passport {
margin-top: $body-mt;
}
.form-fields {
margin-top: $body-mt;
.passport-expiry,
.nationality,
.passport-number {
margin-top: 16px;
}
select#nationality {
padding: 0.675em 52px 0.675em 20px;
white-space: nowrap;
text-overflow: ellipsis;
}
.passport-expiry {
@media screen and (max-width: $mq-medium) {
input {
appearance: none;
--webkit-appearance: none;
&::-webkit-date-and-time-value {
text-align: left;
}
}
}
}
.passport 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;
}
}
}
.passport-expiry.untouched-element,
.nationality.untouched-element {
input,
select {
color: #80a7cf;
}
}
}
<div class="registration-passport-details 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="passport">
<img src="/assets/example-content/rectangleGuideline.svg" alt="rectangleGuideline">
</div>
<div class="form-fields">
<div class="place-of-birth">
{{render '@registration-text-input' placeOfBirth merge="true"}}
</div>
<div class="passport-number">
{{render '@registration-text-input' passportNumber merge="true"}}
</div>
<div class="passport-expiry untouched-element">
{{render '@registration-text-input' passportExpiry merge="true"}}
</div>
<div class="nationality untouched-element">
{{render '@custom-input-select' nationality merge="true"}}
</div>
<div class="cta">
<div class="next-to-step-5">
{{render '@cta--r-disabled' nextBtn merge="true"}}
</div>
<div class="next-to-step-3">
{{render '@cta--r-secondary' uploadNewPhoto merge="true"}}
</div>
</div>
</div>
</div>