Remove redundant note validation logic from product forms

Simplifies note handling by eliminating duplicate and unnecessary validation checks. Ensures the workflow remains functional while reducing code complexity and potential redundancy across components.
This commit is contained in:
Jepp9350
2025-03-13 14:59:23 +01:00
parent a3aec14e74
commit 4c4a998b84
2 changed files with 9 additions and 21 deletions
@@ -110,11 +110,6 @@ const onBeforeToggleProductAddon = (addon, isAddonCurrentlySelected, onAfterPreC
// If the addon is not currently selected, we need to check if it has any requirements
if (doesAddonHaveNoteRequirement(addon)) {
note = prompt('Indtast en note til tilvalget');
if (!note) { Swal.fire(
'Fejl',
'Du skal indtaste en note for at tilføje dette tilvalg',
'error'
); return; }
}
onAfterPreCheck();
if (note)
@@ -272,23 +272,16 @@ const addProductWithAddonsToOrder = async (product_id) => {
confirmButtonText: 'Tilføj',
showLoaderOnConfirm: true,
preConfirm: (note) => {
// Check if the note is empty
if (note === "") {
Swal.showValidationMessage(
'Du skal tilføje en note'
);
} else {
// Show the fake create order item
showFakeCreateOrderItem(product_id, 1, 0, 0, note);
// Create the order item
createOrderItem(getOrderId(), product_id, 1, 0, note).then(async (result) => {
let order_item_id = result.data.data.id;
// Add the addons to the order
await addAddonsToOrderMiddleware(product_id, 1, order_item_id).then(() => {
loadOrderItems();
});
// Show the fake create order item
showFakeCreateOrderItem(product_id, 1, 0, 0, note);
// Create the order item
createOrderItem(getOrderId(), product_id, 1, 0, note).then(async (result) => {
let order_item_id = result.data.data.id;
// Add the addons to the order
await addAddonsToOrderMiddleware(product_id, 1, order_item_id).then(() => {
loadOrderItems();
});
}
});
},
allowOutsideClick: () => !Swal.isLoading()
});