diff --git a/src/components/Scanner.vue b/src/components/Scanner.vue
index 8002eefe..27cb16df 100644
--- a/src/components/Scanner.vue
+++ b/src/components/Scanner.vue
@@ -1,44 +1,86 @@
-
-
+
+
-
-
+
+
+
+
+ Start Scanning
+
+
-
+
\ No newline at end of file
+ closeOutline,
+ };
+ },
+};
+
+
diff --git a/src/utils/index.ts b/src/utils/index.ts
index b699b0ca..6510aab3 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -52,4 +52,16 @@ const handleDateTimeInput = (dateTimeValue: any) => {
return DateTime.fromISO(dateTime).toMillis()
}
-export { handleDateTimeInput, showToast, hasError, copyToClipboard }
+const hasCameraAccess = async () => {
+ try {
+ const stream = await navigator.mediaDevices.getUserMedia({ video: true });
+ if (stream) {
+ showToast(translate('Camera access granted.'));
+ }
+ } catch (error) {
+ console.error('Camera access denied:', error);
+ showToast(translate('Camera permission is denied. Please enable the camera permission in your device settings to use the scanner.'));
+ }
+}
+
+export { handleDateTimeInput, showToast, hasError, copyToClipboard, hasCameraAccess }
diff --git a/src/views/PurchaseOrderDetail.vue b/src/views/PurchaseOrderDetail.vue
index c55fc3cf..873c06ea 100644
--- a/src/views/PurchaseOrderDetail.vue
+++ b/src/views/PurchaseOrderDetail.vue
@@ -190,6 +190,7 @@ import LocationPopover from '@/components/LocationPopover.vue'
import ImageModal from '@/components/ImageModal.vue';
import { copyToClipboard, hasError, showToast } from '@/utils';
import { Actions, hasPermission } from '@/authorization'
+import { hasCameraAccess } from '@/utils/';
export default defineComponent({
name: "PurchaseOrderDetails",
@@ -249,6 +250,10 @@ export default defineComponent({
return imageModal.present();
},
async scan() {
+ if (!hasCameraAccess()) {
+ showToast(translate("Camera access is required to scan items."));
+ return;
+ }
const modal = await modalController
.create({
component: Scanner,
diff --git a/src/views/ReturnDetails.vue b/src/views/ReturnDetails.vue
index 4b77b2f2..482da038 100644
--- a/src/views/ReturnDetails.vue
+++ b/src/views/ReturnDetails.vue
@@ -117,6 +117,7 @@ import ImageModal from '@/components/ImageModal.vue';
import { hasError } from '@/utils';
import { showToast } from '@/utils'
import { Actions, hasPermission } from '@/authorization'
+import { hasCameraAccess } from '@/utils';
export default defineComponent({
name: "ReturnDetails",
@@ -268,6 +269,10 @@ export default defineComponent({
this.queryString = ''
},
async scanCode () {
+ if (!hasCameraAccess()) {
+ showToast(translate("Camera access is required to scan items."));
+ return;
+ }
const modal = await modalController
.create({
component: Scanner,
diff --git a/src/views/ShipmentDetails.vue b/src/views/ShipmentDetails.vue
index 50ff3e44..f7fef24e 100644
--- a/src/views/ShipmentDetails.vue
+++ b/src/views/ShipmentDetails.vue
@@ -123,6 +123,7 @@ import LocationPopover from '@/components/LocationPopover.vue'
import ImageModal from '@/components/ImageModal.vue';
import { hasError, showToast } from '@/utils'
import { Actions, hasPermission } from '@/authorization'
+import { hasCameraAccess } from '@/utils'
export default defineComponent({
name: "ShipmentDetails",
@@ -287,6 +288,10 @@ export default defineComponent({
this.queryString = ''
},
async scanCode () {
+ if (!hasCameraAccess()) {
+ showToast(translate("Camera access is required to scan items."));
+ return;
+ }
const modal = await modalController
.create({
component: Scanner,