aboutsummaryrefslogblamecommitdiffstats
path: root/src/screens/Checkout/CheckoutScreen.js
blob: a8645d221cf479fe93133566f52fa78d927a75c6 (plain) (tree)

























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

const CheckoutScreen = ({ navigation }) => {
  const { cart } = useContext(CartContext);

  const handlePayment = async () => {
    // Simulate payment processing
    alert('Payment successful!');
    await emailService.sendInvoice(cart);
    navigation.navigate('Invoice');
  };

  return (
    <View>
      {cart.map((item, index) => (
        <Text key={index}>{item.name} - ${item.price * item.quantity}</Text>
      ))}
      <Button title="Confirm and Pay" onPress={handlePayment} />
    </View>
  );
};

export default CheckoutScreen;