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:
@@ -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()
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user