aboutsummaryrefslogtreecommitdiffstats
path: root/src/screens/Cart/CartScreen.js
blob: 392e66552141cc4bf757122c8a088e69043c0d8f (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
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;