Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

ProductBarcode: display barcode type in frontend/Scanner.vue

Crumb Owla85bdfef88ae
diff --git a/frontend/components/App/ScannerModal.vue b/frontend/components/App/ScannerModal.vue
index 1f4e049c..91076976 100644
--- a/frontend/components/App/ScannerModal.vue
+++ b/frontend/components/App/ScannerModal.vue
@@ -19,7 +19,7 @@
role="alert"
>
<MdiAlertCircleOutline class="text-default" />
- <span class="text-sm font-medium">Product barcode detected: {{ detectedBarcode }}</span>
+ <span class="text-sm font-medium">{{ detectedBarcodeType }} product barcode detected: {{ detectedBarcode }} </span>
<ButtonGroup>
<Button :disabled="loading" type="submit" @click="handleButtonClick">Fetchdata and create</Button>
@@ -66,6 +66,7 @@
const codeReader = new BrowserMultiFormatReader();
const errorMessage = ref<string | null>(null);
const detectedBarcode = ref<string>("");
+ const detectedBarcodeType = ref<string>("");
const api = useUserApi();
const handleError = (error: unknown) => {
@@ -193,13 +194,16 @@
navigateTo(sanitizedPath);
} catch (err) {
// Check if it's a barcode for a new element
- switch (result.getBarcodeFormat()) {
+ const bcfmt = result.getBarcodeFormat();
+
+ switch (bcfmt) {
case BarcodeFormat.EAN_13:
case BarcodeFormat.UPC_A:
case BarcodeFormat.UPC_E:
case BarcodeFormat.UPC_EAN_EXTENSION:
console.info("Barcode detected");
detectedBarcode.value = result.getText();
+ detectedBarcodeType.value = BarcodeFormat[bcfmt].replaceAll("_","-");
break;
default: