UNPKG

@open-tender/store

Version:

A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our in-store POS API

19 lines (18 loc) 694 B
import { BarcodeScannerType } from './types'; import useBarcode from './useBarcode'; import useBarcodeCameraScanner from './useBarcodeCameraScanner'; import useBarcodeUSB from './useBarcodeUSB'; export var useBarcodeScanner = function (listener, cameraScanner, type, api, close) { var usbScan = useBarcodeUSB(listener); var cameraScan = useBarcodeCameraScanner(cameraScanner, close); var defaultScan = useBarcode(api); switch (type) { case BarcodeScannerType.CAMERA: return cameraScan; case BarcodeScannerType.USB: return usbScan; case BarcodeScannerType.MORPHSTICK: return defaultScan; } return undefined; };