Skip to content

Add scanner-aware product search and barcode validation#37

Open
IanTheMitten wants to merge 1 commit into
mainfrom
codex/add-barcode-scanning-functionality
Open

Add scanner-aware product search and barcode validation#37
IanTheMitten wants to merge 1 commit into
mainfrom
codex/add-barcode-scanning-functionality

Conversation

@IanTheMitten

Copy link
Copy Markdown
Owner

Motivation

  • Improve cashier workflow by supporting keyboard-wedge barcode scanners that emit a rapid key burst followed by Enter and reduce manual steps when a barcode uniquely identifies a product.
  • Prevent invalid or duplicate barcodes at creation time to reduce inventory data errors and provide immediate feedback to the user.

Description

  • Implemented scanner-aware input handling in src/components/cashier/ProductSearch.tsx by tracking recent key timestamps and treating Enter as a scanner submit when a rapid-burst pattern is detected; on a single exact barcode match it calls onAddToCart(product) and clears the input, otherwise shows an inline error and a toast while preserving the input.
  • Updated cashier search placeholder to "Scan barcode here or type manually." and added visible error styling for search failures.
  • Extended src/components/inventory/AddProductModal.tsx with barcode validation including configurable allowed characters via VITE_BARCODE_CHARSET_REGEX, optional length enforcement via VITE_BARCODE_ENFORCE_LENGTH and VITE_BARCODE_ALLOWED_LENGTHS, input sanitization, inline error messages, and pre-submit duplicate checks against in-memory products; server-side barcode conflict errors are handled with a clearer toast fallback.
  • Wired the current product list into the modal by adding an existingProducts prop and passing products from src/components/inventory/InventoryPage.tsx so client-side duplicate checks can run before calling productsAPI.create.

Testing

  • Built the production bundle with npm run build, which completed successfully.
  • Local compile/build checks passed (no runtime build errors reported).

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant