diff --git a/src/components/shop/POSDepartmentProcess.vue b/src/components/shop/POSDepartmentProcess.vue index 622c1be2..ef840490 100644 --- a/src/components/shop/POSDepartmentProcess.vue +++ b/src/components/shop/POSDepartmentProcess.vue @@ -60,6 +60,11 @@ export const setNextStepDelay = (delay) => { /** Define the step functions */ export const nextStep = async (options = {isMobile: false, orderCreation: true}) => { + const normalizedOptions = { + isMobile: false, + orderCreation: true, + ...options, + }; // Check if the delay has passed since the last step (To prevent double clicks) if (nextStepDelay.value > 0) { return; @@ -70,11 +75,11 @@ export const nextStep = async (options = {isMobile: false, orderCreation: true}) clearErrors(); // If the current step is 1, create the order if (step.value === 1) { - if (!options.orderCreation) { + if (normalizedOptions.orderCreation === false) { step.value++; return; } - if (await createOrder(options)) { + if (await createOrder(normalizedOptions)) { step.value++; } return; @@ -174,12 +179,13 @@ watch([reg_1, reg_2, reg_3], () => { }); /** Get the order details by order id */ -export const getOrderDetails = async () => { +export const getOrderDetails = async (id = null) => { const token = localStorage.getItem('token'); - if (!token || !order_id.value) { + const targetOrderId = id ?? order_id.value; + if (!token || !targetOrderId) { return null; } - return axios.get(API_URL + '/order?id=' + order_id.value, { + return axios.get(API_URL + '/order?id=' + targetOrderId, { headers: { Authorization: `Bearer ${token}` }