blob: 95d586517d9b8437a838d9de99432a1aa4576065 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
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;
|