diff --git a/src/frontend/src/components/items/QRCode.tsx b/src/frontend/src/components/items/QRCode.tsx
index 00f71596e1..030fffea55 100644
--- a/src/frontend/src/components/items/QRCode.tsx
+++ b/src/frontend/src/components/items/QRCode.tsx
@@ -1,9 +1,12 @@
import { Trans, t } from '@lingui/macro';
import {
+ ActionIcon,
Alert,
Box,
Button,
Code,
+ Divider,
+ Flex,
Group,
Image,
Select,
@@ -12,13 +15,17 @@ import {
Text,
TextInput
} from '@mantine/core';
+import { useDisclosure } from '@mantine/hooks';
import { modals } from '@mantine/modals';
+import { IconQrcode } from '@tabler/icons-react';
import { useQuery } from '@tanstack/react-query';
import QR from 'qrcode';
import { useEffect, useMemo, useState } from 'react';
+import { set } from 'react-hook-form';
import { api } from '../../App';
import { ApiEndpoints } from '../../enums/ApiEndpoints';
+import { InputImageBarcode, ScanItem } from '../../pages/Index/Scan';
import { apiUrl } from '../../states/ApiState';
import { useGlobalSettingsState } from '../../states/SettingsState';
import { CopyButton } from '../buttons/CopyButton';
@@ -142,27 +149,47 @@ export const InvenTreeQRCode = ({
export const QRCodeLink = ({ mdl_prop }: { mdl_prop: QrCodeType }) => {
const [barcode, setBarcode] = useState('');
+ const [isScanning, toggleIsScanning] = useDisclosure(false);
- function linkBarcode() {
+ function linkBarcode(value?: string) {
api
.post(apiUrl(ApiEndpoints.barcode_link), {
[mdl_prop.model]: mdl_prop.pk,
- barcode: barcode
+ barcode: value || barcode
})
.then((response) => {
modals.closeAll();
location.reload();
});
}
+ const actionSubmit = (data: ScanItem[]) => {
+ linkBarcode(data[0].data);
+ };
return (
+ {isScanning ? (
+ <>
+
+
+ >
+ ) : null}
setBarcode(event.currentTarget.value)}
placeholder={t`Scan barcode data here using barcode scanner`}
+ leftSection={
+
+
+
+ }
+ w="100%"
/>
-
diff --git a/src/frontend/src/pages/Index/Scan.tsx b/src/frontend/src/pages/Index/Scan.tsx
index 3b5cf56c4f..7b6c45891c 100644
--- a/src/frontend/src/pages/Index/Scan.tsx
+++ b/src/frontend/src/pages/Index/Scan.tsx
@@ -55,7 +55,7 @@ import { notYetImplemented } from '../../functions/notifications';
import { IS_DEV_OR_DEMO } from '../../main';
import { apiUrl } from '../../states/ApiState';
-interface ScanItem {
+export interface ScanItem {
id: string;
ref: string;
data: any;
@@ -545,7 +545,7 @@ function InputManual({ action }: Readonly) {
}
/* Input that uses QR code detection from images */
-function InputImageBarcode({ action }: Readonly) {
+export function InputImageBarcode({ action }: Readonly) {
const [qrCodeScanner, setQrCodeScanner] = useState(null);
const [camId, setCamId] = useLocalStorage({
key: 'camId',
@@ -714,17 +714,19 @@ function InputImageBarcode({ action }: Readonly) {
return (
-
+