Skip to content

Commit

Permalink
merge address confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbarnes9 committed Jun 29, 2020
1 parent db4b3a0 commit 4960d93
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 195 deletions.
Binary file modified _fonts/.DS_Store
Binary file not shown.
163 changes: 0 additions & 163 deletions _prototypes/end-to-end/confirm-address.html

This file was deleted.

67 changes: 46 additions & 21 deletions _prototypes/end-to-end/confirm-rh-address.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h1 class="question__title u-fs-xl">
<div class="field__item js-focusable-box">
<input autocomplete="new-password" class="input input--radio js-focusable" type="radio"
name="address-correct" id="address-correct-no">
<label class="label label--inline" for="address-correct-no">No, search for address again</label>
<label id="address-correct-no-label" class="label label--inline" for="address-correct-no">No, search for address again</label>
</div>
</fieldset>
</div>
Expand All @@ -74,6 +74,7 @@ <h1 class="question__title u-fs-xl">

<script>
var yesbox = document.getElementById("address-correct-yes");
var nobox = document.getElementById("address-correct-no");
var urlParams = new URLSearchParams(window.location.search);
var previousPage = urlParams.get('previous');
var addressParam = urlParams.get('address');
Expand All @@ -89,34 +90,57 @@ <h1 class="question__title u-fs-xl">
var addressLine3 = addressLines[2];
var addressLine4 = addressLines[3];
var roomNumber = (sessionStorage.getItem('ce-room-number') || '');

console.log(currentJourney);
$('.qa-btn-submit').on('click', function (e) {
e.preventDefault();

/**
* Routing
*/
// Correct address
if (yesbox.checked) {
if (addressCountry === 'S') {
var url = '../address-in-scotland';
} else if (addressCountry != 'S' && addressType === 'CE') {
var url = '../confirm-rh-address-ce';
} else if (currentJourney === 'new-hh-paper') {
var url = '../paper-request-hh-number';
} else if (currentJourney === 'unlinked-uac') {
var url = '../section-intro';
// UAC entered
if (previousPage === 'uac-entry') {
var url = '../section-intro';
}
// Fulfilment
else if (previousPage === 'uac-request-address' && currentJourney != 'address-correction') {
// Address in England or Wales
if (addressCountry === 'E' || addressCountry === 'W') {
// CE address
if (addressType === 'CE') {
var url = '../confirm-rh-address-ce';
}
// Household address
else {
// HH Paper fulfilment
if (currentJourney === 'new-hh-paper') {
var url = '../paper-request-hh-number';
// HH Code fulfilment
} else {
var url = '../uac-request-method';
}
}
}
// Address outside England or Wales
else {
var url = '../address-in-scotland';
}
} else {
var url = '../uac-request-method';
var url = '../section-intro';
}
sessionStorage.setItem('address-line-1', addressLine1);
sessionStorage.setItem('address-line-2', addressLine2);
sessionStorage.setItem('address-town', addressLine3);
sessionStorage.setItem('address-postcode', addressLine4);

sessionStorage.setItem('address-line-1', addressLine1);
sessionStorage.setItem('address-line-2', addressLine2);
sessionStorage.setItem('address-town', addressLine3);
sessionStorage.setItem('address-postcode', addressLine4);

window.location.href = url + '?' + 'previous=' + currentPage + '&' + 'current-journey=' + currentJourney;
}
else {
else if (nobox.checked) {
var url = '../uac-request-address';
window.location.href = url + '?' + 'previous=' + currentPage + '&' + 'current-journey=address-correction';
}
window.location.href = url + '?' + 'previous=' + currentPage + '&' + 'current-journey=' + currentJourney;
});

if (addressParam) {
Expand Down Expand Up @@ -169,12 +193,13 @@ <h1 class="question__title u-fs-xl">
}
}

function updateAnswer() {
if (addressCountry === 'S') {
$('.js-change-address').hide();
function updateTemplate() {
if (previousPage === 'uac-entry') {
$('#address-correct-no-label').html('No, this is not the correct address');
// $('.complete-later').hide();
}
}

$(updateAllLinks);
$(updateAnswer);
$(updateTemplate);
</script>
16 changes: 16 additions & 0 deletions _prototypes/end-to-end/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@
sessionStorage.setItem('address-town', document.getElementById('address-town').value);
sessionStorage.setItem('address-postcode', document.getElementById('address-postcode').value);

// Temporary manual update address type for CEs
var addressLine1 = document.getElementById('address-line-1').value.toLowerCase();
var addressLine2 = document.getElementById('address-line-2').value.toLowerCase();
var address = addressLine1 + addressLine2;
var array = [
"university",
"howden apartments",
"care home",
"halls of residence",
"hall of residence"
];

if (array.some(val => address.includes(val))) {
sessionStorage.setItem('address-type', 'CE');
}

window.location = '../home/';
}
});
Expand Down
3 changes: 1 addition & 2 deletions _prototypes/end-to-end/uac-entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
layout: eq-default-extras
footer: census-transactional
assetPrefixUrl: https://sdc-global-design-patterns.netlify.com
hideSaveLater: true
logoUrl: ../home
---

Expand Down Expand Up @@ -130,7 +129,7 @@ <h3 class="collapsible__title js-collapsible-title icon--collapsible-simple u-fs
if (uacInput.value == 'unl1 nk3d acc3 55c0') {
window.location = '../uac-request-address/?previous=uac-entry&current-journey=unlinked-uac';
} else {
window.location = '../confirm-address/';
window.location = '../confirm-rh-address/?previous=uac-entry';
}
}
});
Expand Down
18 changes: 9 additions & 9 deletions _prototypes/end-to-end/uac-request-address.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
currentJourney = urlParams.get('current-journey'),
currentPage = 'uac-request-address',
hasErrors = false;

console.log(currentJourney);
$('.btn-submit').click(function(e) {
e.preventDefault(); // do not submit the form like usual
if (($("input[id='rh-proto-address']").val() == '') || ($('#address-typeahead-listbox').html().length)) {
Expand Down Expand Up @@ -146,20 +146,12 @@

if (array.some(val => address.includes(val))) {
sessionStorage.setItem('address-type', 'CE');
var currentJourney = 'new-ce-resident-uac';
} else {
var currentJourney = urlParams.get('current-journey');
}

window.location = '../confirm-rh-address/?' + 'previous=' + 'uac-request-address' + '&' + 'current-journey=' + currentJourney;
}
});

if(currentJourney === 'unlinked-uac'){
$('.js-question-description').hide();
$('.js-previous-link').hide();
}

if (window.location.search == '?edit=true') {
function updateEditableAddress() {
$('#rh-proto-address').val(sessionStorage.getItem('address'));
Expand All @@ -182,6 +174,14 @@
}

function updateAllLinks() {

if(currentJourney === 'unlinked-uac'){
$('.js-question-description').hide();
$('.js-previous-link').hide();
} else if(currentJourney === 'address-correction'){
$('.js-question-description').hide();
}

if (previousPage) {
$('.js-previous-link').attr('href', '../' + previousPage);
} else {
Expand Down
2 changes: 2 additions & 0 deletions _prototypes/end-to-end/uac-request-confirm-address.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ <h2 class="u-fs-m">Large print</h2>
} else {
$('.js-name-address').html('<strong>' + addresseeName + '</strong>' + ', ' + roomNumber + '<br>' + addressLine1);
}
} else {
$('.js-name-address').html('<strong>' + addresseeName + '</strong>' + '<br>' + addressLine1);
}
}

Expand Down

0 comments on commit 4960d93

Please sign in to comment.