Naprawa buga związanego z walidacją kodu pocztowego

This commit is contained in:
2024-01-16 10:07:07 +01:00
parent 842a2c5309
commit 8462d4932c
3 changed files with 15 additions and 16 deletions

View File

@@ -765,8 +765,6 @@ async function changeRegion(payAndDelData = null, firstLoad = false) {
// Pobranie informacji o regionie z formularza // Pobranie informacji o regionie z formularza
const clientRegion = document.getElementById("client_region").value; const clientRegion = document.getElementById("client_region").value;
const deliveryRegion = document.getElementById("deliver_to_billingaddr").checked ? document.getElementById("delivery_region").value : clientRegion; const deliveryRegion = document.getElementById("deliver_to_billingaddr").checked ? document.getElementById("delivery_region").value : clientRegion;
// Zmiana regionu // Zmiana regionu
const regionStatus = await this.fetchData({ const regionStatus = await this.fetchData({
@@ -1592,11 +1590,11 @@ async function validateAllInputs(){
allGood = await validateRequest(document.getElementById("client_nip"), true) && allGood; allGood = await validateRequest(document.getElementById("client_nip"), true) && allGood;
} }
// Sprawdzenie reszty pól // Sprawdzenie reszty pól
allGood = validateFormInputs("client") && allGood; allGood = await validateFormInputs("client") && allGood;
} }
// Sprawdzanie pól dostawy na inny adres // Sprawdzanie pól dostawy na inny adres
if(document.getElementById("deliver_to_billingaddr").checked){ if(document.getElementById("deliver_to_billingaddr").checked){
allGood = validateFormInputs("delivery") && allGood; allGood = await validateFormInputs("delivery") && allGood;
allGood = validatePhone(document.getElementById("delivery_phone")) && allGood; allGood = validatePhone(document.getElementById("delivery_phone")) && allGood;
} }
return allGood return allGood
@@ -1616,12 +1614,13 @@ async function validateFormInputs(query){
// Obsługa złożenia zamówienia // Obsługa złożenia zamówienia
const termsConditionsInput = document.getElementById("order2_terms_conditions"); const termsConditionsInput = document.getElementById("order2_terms_conditions");
const cancelConditionsInput = document.getElementById("order2_cancel"); const cancelConditionsInput = document.getElementById("order2_cancel");
document.querySelector(".order2_button_order").addEventListener("click", () => { document.querySelector(".order2_button_order").addEventListener("click", async () => {
try { try {
app_shop.fn.ajaxLoadSite(1); app_shop.fn.ajaxLoadSite(1);
app_shop.vars.validation = 1; app_shop.vars.validation = 1;
// Sprawdzenie pól formularza // Sprawdzenie pól formularza
if(validateAllInputs() === false) app_shop.vars.validation = 0; const x = await validateAllInputs();
if(x === false) app_shop.vars.validation = 0;
// Znalezienie obecnie zaznaczonej metody dostawy i płatności // Znalezienie obecnie zaznaczonej metody dostawy i płatności
const deliveryMethod = document.querySelector(".ajax_cop [name=shipping]:checked"); const deliveryMethod = document.querySelector(".ajax_cop [name=shipping]:checked");
@@ -1682,7 +1681,7 @@ document.querySelector(".order2_button_order").addEventListener("click", () => {
}); });
// Przescrolluj do // Przescrolluj do
function scrollToHeight(scrollToEl){ function scrollToHeight(scrollToEl){
const yOffset = -45; const yOffset = app_shop.vars.view === 1 ? -100 : -45;
const y = scrollToEl.getBoundingClientRect().top + window.pageYOffset + yOffset; const y = scrollToEl.getBoundingClientRect().top + window.pageYOffset + yOffset;
window.scrollTo({top: y, behavior: 'smooth'}); window.scrollTo({top: y, behavior: 'smooth'});
} }

View File

@@ -518,8 +518,9 @@
cursor: pointer; cursor: pointer;
display: flex; display: flex;
align-items: center; align-items: center;
top: 0; top: 12%;
height: 100%; height: 75%;
background: #fff;
} }
#toggle_password:hover{ #toggle_password:hover{
color: @less_iaicolorscheme_background_active_color; color: @less_iaicolorscheme_background_active_color;

View File

@@ -762,8 +762,6 @@ async function changeRegion(payAndDelData = null, firstLoad = false) {
const clientRegion = document.getElementById("client_region").value; const clientRegion = document.getElementById("client_region").value;
const deliveryRegion = document.getElementById("deliver_to_billingaddr").checked ? document.getElementById("delivery_region").value : clientRegion; const deliveryRegion = document.getElementById("deliver_to_billingaddr").checked ? document.getElementById("delivery_region").value : clientRegion;
// Zmiana regionu // Zmiana regionu
const regionStatus = await this.fetchData({ const regionStatus = await this.fetchData({
data: SET_REGION(`SetRegionInput: { data: SET_REGION(`SetRegionInput: {
@@ -1588,11 +1586,11 @@ async function validateAllInputs(){
allGood = await validateRequest(document.getElementById("client_nip"), true) && allGood; allGood = await validateRequest(document.getElementById("client_nip"), true) && allGood;
} }
// Sprawdzenie reszty pól // Sprawdzenie reszty pól
allGood = validateFormInputs("client") && allGood; allGood = await validateFormInputs("client") && allGood;
} }
// Sprawdzanie pól dostawy na inny adres // Sprawdzanie pól dostawy na inny adres
if(document.getElementById("deliver_to_billingaddr").checked){ if(document.getElementById("deliver_to_billingaddr").checked){
allGood = validateFormInputs("delivery") && allGood; allGood = await validateFormInputs("delivery") && allGood;
allGood = validatePhone(document.getElementById("delivery_phone")) && allGood; allGood = validatePhone(document.getElementById("delivery_phone")) && allGood;
} }
return allGood return allGood
@@ -1612,12 +1610,13 @@ async function validateFormInputs(query){
// Obsługa złożenia zamówienia // Obsługa złożenia zamówienia
const termsConditionsInput = document.getElementById("order2_terms_conditions"); const termsConditionsInput = document.getElementById("order2_terms_conditions");
const cancelConditionsInput = document.getElementById("order2_cancel"); const cancelConditionsInput = document.getElementById("order2_cancel");
document.querySelector(".order2_button_order").addEventListener("click", () => { document.querySelector(".order2_button_order").addEventListener("click", async () => {
try { try {
app_shop.fn.ajaxLoadSite(1); app_shop.fn.ajaxLoadSite(1);
app_shop.vars.validation = 1; app_shop.vars.validation = 1;
// Sprawdzenie pól formularza // Sprawdzenie pól formularza
if(validateAllInputs() === false) app_shop.vars.validation = 0; const x = await validateAllInputs();
if(x === false) app_shop.vars.validation = 0;
// Znalezienie obecnie zaznaczonej metody dostawy i płatności // Znalezienie obecnie zaznaczonej metody dostawy i płatności
const deliveryMethod = document.querySelector(".ajax_cop [name=shipping]:checked"); const deliveryMethod = document.querySelector(".ajax_cop [name=shipping]:checked");
@@ -1678,7 +1677,7 @@ document.querySelector(".order2_button_order").addEventListener("click", () => {
}); });
// Przescrolluj do // Przescrolluj do
function scrollToHeight(scrollToEl){ function scrollToHeight(scrollToEl){
const yOffset = -45; const yOffset = app_shop.vars.view === 1 ? -100 : -45;
const y = scrollToEl.getBoundingClientRect().top + window.pageYOffset + yOffset; const y = scrollToEl.getBoundingClientRect().top + window.pageYOffset + yOffset;
window.scrollTo({top: y, behavior: 'smooth'}); window.scrollTo({top: y, behavior: 'smooth'});
} }