summaryrefslogblamecommitdiffstats
path: root/src/screens/ProductScannerScreen.js
blob: 35926e10b570f19f25495a1315b86c505ad9234e (plain) (tree)
1
2
3

                                                  
                                                          

























                                                                  
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;