OTC-Submit-Reset korrigieren
This commit is contained in:
@@ -387,7 +387,7 @@ function render_auth_home_page(array $user, array $otcProducts = []): void
|
|||||||
echo " if (totalPriceInput) { totalPriceInput.value = '0.00'; }";
|
echo " if (totalPriceInput) { totalPriceInput.value = '0.00'; }";
|
||||||
echo " clearError();";
|
echo " clearError();";
|
||||||
echo " if (!preserveSuccess) { clearSuccess(); }";
|
echo " if (!preserveSuccess) { clearSuccess(); }";
|
||||||
echo " updateFormState();";
|
echo " if (!preserveSuccess) { updateFormState(); }";
|
||||||
echo " };";
|
echo " };";
|
||||||
echo " document.addEventListener('click', (event) => {";
|
echo " document.addEventListener('click', (event) => {";
|
||||||
echo " const openTrigger = event.target.closest('[data-otc-order-open]');";
|
echo " const openTrigger = event.target.closest('[data-otc-order-open]');";
|
||||||
@@ -423,10 +423,11 @@ function render_auth_home_page(array $user, array $otcProducts = []): void
|
|||||||
echo " });";
|
echo " });";
|
||||||
echo " form.addEventListener('submit', async (event) => {";
|
echo " form.addEventListener('submit', async (event) => {";
|
||||||
echo " event.preventDefault();";
|
echo " event.preventDefault();";
|
||||||
|
echo " let submissionSucceeded = false;";
|
||||||
echo " if (!updateFormState()) { return; }";
|
echo " if (!updateFormState()) { return; }";
|
||||||
echo " const products = productInputs";
|
echo " const products = productInputs";
|
||||||
echo " .filter((input) => getInputValue(input) > 0)";
|
echo " .filter((input) => getInputValue(input) > 0)";
|
||||||
echo " .map((input) => ({ title: input.dataset.title, qty: getInputValue(input), productId: parseInt(input.dataset.productId || '0', 10) }));";
|
echo " .map((input) => ({ title: input.dataset.title, qty: getInputValue(input) }));";
|
||||||
echo " const orderData = {";
|
echo " const orderData = {";
|
||||||
echo " products: products,";
|
echo " products: products,";
|
||||||
echo " totalPrice: parseFloat(totalPriceInput.value || '0') || 0,";
|
echo " totalPrice: parseFloat(totalPriceInput.value || '0') || 0,";
|
||||||
@@ -452,6 +453,7 @@ function render_auth_home_page(array $user, array $otcProducts = []): void
|
|||||||
echo " });";
|
echo " });";
|
||||||
echo " const result = await response.json();";
|
echo " const result = await response.json();";
|
||||||
echo " if (response.ok && result.ok) {";
|
echo " if (response.ok && result.ok) {";
|
||||||
|
echo " submissionSucceeded = true;";
|
||||||
echo " if (successEl) {";
|
echo " if (successEl) {";
|
||||||
echo " successEl.textContent = result.externalRef ? 'Bestellung erfolgreich erfasst! Bestellnummer: ' + result.externalRef : successDefaultText;";
|
echo " successEl.textContent = result.externalRef ? 'Bestellung erfolgreich erfasst! Bestellnummer: ' + result.externalRef : successDefaultText;";
|
||||||
echo " successEl.classList.remove('hidden');";
|
echo " successEl.classList.remove('hidden');";
|
||||||
@@ -468,7 +470,7 @@ function render_auth_home_page(array $user, array $otcProducts = []): void
|
|||||||
echo " }";
|
echo " }";
|
||||||
echo " } finally {";
|
echo " } finally {";
|
||||||
echo " submitBtn.innerHTML = originalBtnText;";
|
echo " submitBtn.innerHTML = originalBtnText;";
|
||||||
echo " updateFormState();";
|
echo " if (!submissionSucceeded) { updateFormState(); }";
|
||||||
echo " }";
|
echo " }";
|
||||||
echo " });";
|
echo " });";
|
||||||
echo " updateFormState();";
|
echo " updateFormState();";
|
||||||
|
|||||||
Reference in New Issue
Block a user