mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-21 21:33:02 +01:00
ProductBarcode: improve error handling in BarcodeModal
This commit is contained in:
@@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
<form class="flex flex-col gap-4" @submit.prevent="submitCsvFile">
|
<form class="flex flex-col gap-4" @submit.prevent="submitCsvFile">
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button type="import" :disabled="selectedRow === -1" @click=createItem> Import selected </Button>
|
<Button type="import" :disabled="selectedRow === -1" @click="createItem"> Import selected </Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</form>
|
</form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
@@ -152,14 +152,29 @@
|
|||||||
async function retrieveProductInfo(barcode: string) {
|
async function retrieveProductInfo(barcode: string) {
|
||||||
products.value = null;
|
products.value = null;
|
||||||
searching.value = true;
|
searching.value = true;
|
||||||
const result = await api.products.searchFromBarcode(barcode);
|
|
||||||
searching.value = false;
|
|
||||||
|
|
||||||
|
if (!barcode || barcode.trim().length === 0) {
|
||||||
|
console.error('Invalid barcode provided');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await api.products.searchFromBarcode(barcode.trim());
|
||||||
if(result.error)
|
if(result.error)
|
||||||
return
|
{
|
||||||
|
console.error('API Error:', result.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
products.value = result.data;
|
products.value = result.data;
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to retrieve product info:', error);
|
||||||
|
} finally {
|
||||||
|
searching.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function extractValue(data: TableData, value: string) {
|
function extractValue(data: TableData, value: string) {
|
||||||
const parts = value.split(".");
|
const parts = value.split(".");
|
||||||
|
|||||||
Reference in New Issue
Block a user