diff --git a/frontend/components/Item/BarcodeModal.vue b/frontend/components/Item/BarcodeModal.vue
index a31e462b..571702ac 100644
--- a/frontend/components/Item/BarcodeModal.vue
+++ b/frontend/components/Item/BarcodeModal.vue
@@ -5,6 +5,15 @@
{{ $t("components.item.product_import.title") }}
+
+
+ {{ errorMessage }}
+
+
("");
const products = ref(null);
const selectedRow = ref(-1);
+ const errorMessage = ref(null);
type BarcodeTableHeader = {
text: string;
@@ -139,6 +150,7 @@
registerOpenDialogCallback(DialogID.ProductImport, params => {
selectedRow.value = -1;
searching.value = false;
+ errorMessage.value = null;
if (params?.barcode) {
// Reset if the barcode is different
@@ -166,8 +178,11 @@
}
async function retrieveProductInfo(barcode: string) {
- if (!barcode || barcode.trim().length === 0) {
- console.error("Invalid barcode provided");
+ errorMessage.value = null;
+
+ if (!barcode || barcode.trim().length === 0 || !(/^[0-9]+$/.test(barcode))) {
+ errorMessage.value = "Invalid barcode provided";
+ console.error(errorMessage.value);
return;
}
@@ -177,12 +192,14 @@
try {
const result = await api.products.searchFromBarcode(barcode.trim());
if (result.error) {
- console.error("API Error:", result.error);
+ errorMessage.value = "API Error: " + result.error;
+ console.error(errorMessage.value);
} else {
products.value = result.data;
}
} catch (error) {
- console.error("Failed to retrieve product info:", error);
+ errorMessage.value = "Failed to retrieve product info: " + error;
+ console.error(errorMessage.value);
} finally {
searching.value = false;
}