mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-04 06:18:48 +00:00
parent
8df34cefd6
commit
347f7ea050
@ -14,6 +14,7 @@ import { IconCamera, IconScan } from '@tabler/icons-react';
|
|||||||
import { useCallback, useMemo, useState } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { useLocalStorage } from '@mantine/hooks';
|
import { useLocalStorage } from '@mantine/hooks';
|
||||||
|
import { useGlobalSettingsState } from '../../states/SettingsState';
|
||||||
import { Boundary } from '../Boundary';
|
import { Boundary } from '../Boundary';
|
||||||
import BarcodeCameraInput from './BarcodeCameraInput';
|
import BarcodeCameraInput from './BarcodeCameraInput';
|
||||||
import BarcodeKeyboardInput from './BarcodeKeyboardInput';
|
import BarcodeKeyboardInput from './BarcodeKeyboardInput';
|
||||||
@ -33,6 +34,8 @@ export function BarcodeInput({
|
|||||||
label = t`Barcode`,
|
label = t`Barcode`,
|
||||||
actionText = t`Scan`
|
actionText = t`Scan`
|
||||||
}: Readonly<BarcodeInputProps>) {
|
}: Readonly<BarcodeInputProps>) {
|
||||||
|
const globalSettings = useGlobalSettingsState();
|
||||||
|
|
||||||
const [barcode, setBarcode] = useState<string>('');
|
const [barcode, setBarcode] = useState<string>('');
|
||||||
|
|
||||||
const [inputType, setInputType] = useLocalStorage<string | null>({
|
const [inputType, setInputType] = useLocalStorage<string | null>({
|
||||||
@ -43,15 +46,16 @@ export function BarcodeInput({
|
|||||||
const scanningOptions: SegmentedControlItem[] = useMemo(() => {
|
const scanningOptions: SegmentedControlItem[] = useMemo(() => {
|
||||||
const options: SegmentedControlItem[] = [];
|
const options: SegmentedControlItem[] = [];
|
||||||
|
|
||||||
// TODO : Hide camera input optionally
|
if (globalSettings.isSet('BARCODE_WEBCAM_SUPPORT', true)) {
|
||||||
options.push({
|
options.push({
|
||||||
value: 'camera',
|
value: 'camera',
|
||||||
label: (
|
label: (
|
||||||
<Tooltip label={t`Camera Input`}>
|
<Tooltip label={t`Camera Input`}>
|
||||||
<IconCamera size={20} aria-label='barcode-input-camera' />
|
<IconCamera size={20} aria-label='barcode-input-camera' />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
options.push({
|
options.push({
|
||||||
value: 'scanner',
|
value: 'scanner',
|
||||||
@ -63,7 +67,7 @@ export function BarcodeInput({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}, []);
|
}, [globalSettings]);
|
||||||
|
|
||||||
const onScanBarcode = useCallback(
|
const onScanBarcode = useCallback(
|
||||||
(barcode: string) => {
|
(barcode: string) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user