aboutsummaryrefslogtreecommitdiffstats
path: root/src/screens/Checkout
diff options
context:
space:
mode:
Diffstat (limited to 'src/screens/Checkout')
-rw-r--r--src/screens/Checkout/CheckoutScreen.js75
1 files changed, 70 insertions, 5 deletions
diff --git a/src/screens/Checkout/CheckoutScreen.js b/src/screens/Checkout/CheckoutScreen.js
index a8645d2..4cd8938 100644
--- a/src/screens/Checkout/CheckoutScreen.js
+++ b/src/screens/Checkout/CheckoutScreen.js
@@ -1,5 +1,5 @@
import React, { useContext } from 'react';
-import { View, Text, Button } from 'react-native';
+import { View, Text, Button, StyleSheet, ScrollView } from 'react-native';
import { CartContext } from '../../context/CartContext';
import emailService from '../../services/emailService';
@@ -13,14 +13,79 @@ const CheckoutScreen = ({ navigation }) => {
navigation.navigate('Invoice');
};
+ const totalAmount = cart.reduce((total, item) => total + item.price * item.quantity, 0);
+
return (
- <View>
+ <ScrollView contentContainerStyle={styles.container}>
+ <Text style={styles.title}>Checkout</Text>
{cart.map((item, index) => (
- <Text key={index}>{item.name} - ${item.price * item.quantity}</Text>
+ <View key={index} style={styles.itemContainer}>
+ <Text style={styles.itemText}>{item.name}</Text>
+ <Text style={styles.priceText}>${(item.price * item.quantity).toFixed(2)}</Text>
+ </View>
))}
- <Button title="Confirm and Pay" onPress={handlePayment} />
- </View>
+ <View style={styles.totalContainer}>
+ <Text style={styles.totalText}>Total: ${totalAmount.toFixed(2)}</Text>
+ </View>
+ <View style={styles.buttonContainer}>
+ <Button title="Confirm and Pay" onPress={handlePayment} />
+ </View>
+ </ScrollView>
);
};
+const styles = StyleSheet.create({
+ container: {
+ padding: 16,
+ backgroundColor: '#f8f9fa',
+ },
+ title: {
+ fontSize: 24,
+ fontWeight: 'bold',
+ marginBottom: 20,
+ textAlign: 'center',
+ },
+ itemContainer: {
+ backgroundColor: '#ffffff',
+ padding: 16,
+ borderRadius: 8,
+ marginBottom: 12,
+ elevation: 2,
+ shadowColor: '#000',
+ shadowOpacity: 0.2,
+ shadowRadius: 3,
+ shadowOffset: { width: 1, height: 2 },
+ },
+ itemText: {
+ fontSize: 18,
+ color: '#333',
+ },
+ priceText: {
+ fontSize: 16,
+ color: '#888',
+ },
+ totalContainer: {
+ marginTop: 20,
+ padding: 16,
+ backgroundColor: '#ffffff',
+ borderRadius: 8,
+ elevation: 2,
+ shadowColor: '#000',
+ shadowOpacity: 0.2,
+ shadowRadius: 3,
+ shadowOffset: { width: 1, height: 2 },
+ },
+ totalText: {
+ fontSize: 20,
+ fontWeight: 'bold',
+ textAlign: 'center',
+ color: '#333',
+ },
+ buttonContainer: {
+ marginTop: 20,
+ borderRadius: 8,
+ },
+});
+
export default CheckoutScreen;
+