Refactor SelectProductsFormPOS.vue to use optional chaining for route parameter access and improve department ID fallback logic.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user