import React, { useState } from 'react'; import { View, Text, ScrollView, TextInput, TouchableOpacity, } from 'react-native'; import { useNavigation } from '@react-navigation/native'; import { StackNavigationProp } from '@react-navigation/stack'; import { getStyles } from './cartScreen.styles'; import { Header, QuantitySelector, PrimaryButton } from '@components'; import { useAppTheme } from '@theme'; import { removeItem, applyCoupon, removeCoupon, selectCartTotal, } from '../../../store/commonreducers/cart'; import { AppStackParamList } from '../../../navigation/appStack'; import { useAppDispatch, useAppSelector } from '@store'; type CartScreenNavProp = StackNavigationProp; export const CartScreen: React.FC = () => { const { colors } = useAppTheme(); const styles = getStyles(colors); const dispatch = useAppDispatch(); const navigation = useNavigation(); const { items, couponCode } = useAppSelector(state => state.cart); const totals = useAppSelector(selectCartTotal); const [couponInput, setCouponInput] = useState(''); const handleCouponPress = () => { if (couponCode) { dispatch(removeCoupon()); setCouponInput(''); } else if (couponInput) { dispatch(applyCoupon(couponInput)); } }; if (items.length === 0) { return (
navigation.goBack()} /> 🛒 Your cart is empty Looks like you haven't added anything yet. Browse providers and find something you'll love. navigation.goBack()} > Start Ordering ); } return (
navigation.goBack()} /> 🛵 Delivery in 20–25 mins {items.map((item, index) => ( 🍕 {item.item.title} ₹{item.item.price} {}} onDecrement={() => dispatch(removeItem(item.item.id))} /> ))} navigation.goBack()} > + Add more items Apply Coupon {couponCode ? ( {couponCode} Coupon applied Remove ) : ( 🏷️ Apply )} Bill Details Subtotal ₹{totals.subtotal} Delivery Fee ₹{totals.deliveryFee} Platform Fee ₹{totals.platformFee} {totals.discount > 0 && ( Discount -₹{totals.discount} )} Total ₹{totals.total} {totals.discount > 0 && ( 🎉 You're saving ₹{totals.discount} on this order )} Total ₹{totals.total} navigation.navigate('CheckoutAddressScreen')} style={styles.checkoutButton} /> ); };