ProductBarcode: display barcode type in frontend/Scanner.vue

This commit is contained in:
Crumb Owl
2025-07-01 11:41:33 +02:00
parent 79baf6b5ef
commit a85bdfef88

View File

@@ -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: