diff --git a/src/components/forms/department/pos/SelectProductsFormPOS.vue b/src/components/forms/department/pos/SelectProductsFormPOS.vue index 86b3a3be..6322033a 100644 --- a/src/components/forms/department/pos/SelectProductsFormPOS.vue +++ b/src/components/forms/department/pos/SelectProductsFormPOS.vue @@ -256,6 +256,44 @@ const setProductAddonQuantity = (productId, addonId, quantity) => { }; const addProductWithAddonsToOrder = async (product_id) => { + // Check if the product requires a note + const product = products.value.find((product) => product.id === product_id); + if (product.requires_note) { + // Show the note input + await Swal.fire({ + title: 'Tilføj en note', + input: 'text', + inputLabel: 'Noten kan ses af kunden. F.eks. "Fjernelse af graffiti på venstre side"', + inputAttributes: { + autocapitalize: 'off' + }, + showCancelButton: true, + 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(); + }); + }); + } + }, + allowOutsideClick: () => !Swal.isLoading() + }); + return; + } + // If the product requires a note, show the note input console.log(product_id); let quantity = 1; // Show the fake create order item