aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/CartItem.js
blob: da56fbc5e7bb8e28bafdd71b4ab4bd3c267688bd (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 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;