From 5b411de9e690413bfc709abc8a55295254660873 Mon Sep 17 00:00:00 2001 From: Jeppe Bundgaard Date: Thu, 19 Mar 2026 12:12:20 +0100 Subject: [PATCH] Refactor `SelectProductsFormPOS.vue` to use optional chaining for route parameter access and improve department ID fallback logic. --- .../forms/department/pos/SelectProductsFormPOS.vue | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/forms/department/pos/SelectProductsFormPOS.vue b/src/components/forms/department/pos/SelectProductsFormPOS.vue index 7d47e199..2e62ee4b 100644 --- a/src/components/forms/department/pos/SelectProductsFormPOS.vue +++ b/src/components/forms/department/pos/SelectProductsFormPOS.vue @@ -26,6 +26,7 @@ import ProductBox from "@/components/displays/boxes/ProductBox.vue"; import { getPicture } from "@/components/displays/department/pos/displays/Piktogrammer.vue"; import { products_category } from "@/components/shop/POSDepartmentProcess.vue"; const emits = defineEmits(['onAddToCartProduct', 'onAddProduct', 'onSelectProduct']); +const route = useRoute(); const props = defineProps({ isCustomerBooking: { type: Boolean, @@ -229,10 +230,8 @@ const loadCategories = async () => { categories.value = []; // Add the static categories categories.value.push(...categories_static.value); - // Get the department id from the route - const route = useRoute(); // Prefer route param, otherwise fallback to global POS department_id - const departmentId = route.params.departmentId ?? department_id.value; + const departmentId = route?.params?.departmentId ?? department_id.value; // If the department id is not set, return if (departmentId === undefined || departmentId === null) { return;