aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-10-16 16:29:23 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-10-16 16:29:23 +0530
commit4773102af221fc38342869c4ba0b571e02f4400e (patch)
treed972ccf9e869e56f4a37fcdfb5b70b27f49a5e8d /src
parent212ad32783125d09d043c80b38e0342adda07f82 (diff)
downloadmall-app-4773102af221fc38342869c4ba0b571e02f4400e.tar.gz
mall-app-4773102af221fc38342869c4ba0b571e02f4400e.tar.bz2
mall-app-4773102af221fc38342869c4ba0b571e02f4400e.zip
Add CartItem component to display individual items in the cart with quantity adjustment
Diffstat (limited to 'src')
-rw-r--r--src/components/CartItem.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/components/CartItem.js b/src/components/CartItem.js
index e69de29..da56fbc 100644
--- a/src/components/CartItem.js
+++ b/src/components/CartItem.js
@@ -0,0 +1,26 @@
+import React from 'react';
+import { View, Text, Button, StyleSheet } from 'react-native';
+import QuantityAdjuster from './QuantityAdjuster';
+
+const CartItem = ({ item, onUpdateQuantity }) => (
+ <View style={styles.container}>
+ <Text style={styles.name}>{item.name}</Text>
+ <Text style={styles.price}>${item.price.toFixed(2)}</Text>
+ <QuantityAdjuster quantity={item.quantity} onChange={(newQuantity) => onUpdateQuantity(item.id, newQuantity)} />
+ </View>
+);
+
+const styles = StyleSheet.create({
+ container: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ padding: 10,
+ borderBottomWidth: 1,
+ borderColor: '#ccc'
+ },
+ name: { fontSize: 18 },
+ price: { fontSize: 16, color: '#888' },
+});
+
+export default CartItem;