aboutsummaryrefslogblamecommitdiffstats
path: root/src/screens/ProductScannerScreen.js
blob: 95d586517d9b8437a838d9de99432a1aa4576065 (plain) (tree)




























                                                                  
import React, { useState } from 'react';
import { View, Text, Button } from 'react-native';
import BarcodeScanner from '../../components/BarcodeScanner';

const ProductScannerScreen = ({ navigation }) => {
  const [scannedProduct, setScannedProduct] = useState(null);

  const handleScan = (product) => setScannedProduct(product);

  const handleAddToCart = () => {
    // Add product to cart and navigate to cart screen
    navigation.navigate('Cart');
  };

  return (
    <View>
      <BarcodeScanner onScan={handleScan} />
      {scannedProduct && (
        <View>
          <Text>{scannedProduct.name}</Text>
          <Text>{scannedProduct.price}</Text>
          <Button title="Add to Cart" onPress={handleAddToCart} />
        </View>
      )}
    </View>
  );
};

export default ProductScannerScreen;