aboutsummaryrefslogblamecommitdiffstats
path: root/src/screens/Cart/CartScreen.js
blob: 392e66552141cc4bf757122c8a088e69043c0d8f (plain) (tree)






















                                                                                                         
import React, { useContext } from 'react';
import { View, Text, Button } from 'react-native';
import { CartContext } from '../../context/CartContext';

const CartScreen = ({ navigation }) => {
  const { cart, updateQuantity } = useContext(CartContext);

  const handleCheckout = () => navigation.navigate('Checkout');

  return (
    <View>
      {cart.map((item, index) => (
        <View key={index}>
          <Text>{item.name} - Quantity: {item.quantity}</Text>
          <Button title="Increase Quantity" onPress={() => updateQuantity(item.id, item.quantity + 1)} />
        </View>
      ))}
      <Button title="Proceed to Checkout" onPress={handleCheckout} />
    </View>
  );
};

export default CartScreen;