summaryrefslogtreecommitdiffstats
path: root/src/screens/Checkout/CheckoutScreen.js
blob: a8645d221cf479fe93133566f52fa78d927a75c6 (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
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;