From 639ed6b7ab82edd77ea0e34fb67cce34278b5fff Mon Sep 17 00:00:00 2001 From: Jepp9350 <2jepp9350@gmail.com> Date: Fri, 7 Mar 2025 09:05:00 +0100 Subject: [PATCH] Add support for notes on products requiring them If a product requires a note, prompt the user to input it before proceeding. The note is validated to ensure it's not empty and is attached to the order item during creation. This enhances functionality for handling customizable product orders. --- .../department/pos/SelectProductsFormPOS.vue | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) 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