import React, { useEffect } from 'react'; import { View, Text, ScrollView, TouchableOpacity, Image } 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 { selectCartTotal, getCartThunk, updateCartItemThunk, } from '../../../store/commonreducers/cart'; import { AppStackParamList } from '../../../navigation/appStack'; import { useAppDispatch, useAppSelector } from '@store'; import { getFullUrl } from '@utils'; // import { getFullUrl } from '@utils/helperr'; type CartScreenNavProp = StackNavigationProp; export const CartScreen: React.FC = () => { const { colors } = useAppTheme(); const styles = getStyles(colors); const dispatch = useAppDispatch(); const navigation = useNavigation(); const { items, isLoading } = useAppSelector(state => state.cart); const totals = useAppSelector(selectCartTotal); useEffect(() => { dispatch(getCartThunk()); }, [dispatch]); if (!isLoading && 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.product.name} ₹{item.product.price} dispatch( updateCartItemThunk({ productId: item.productId, quantity: item.quantity + 1, }), ) } onDecrement={() => { if (item.quantity >= 1) { dispatch( updateCartItemThunk({ productId: item.productId, quantity: item.quantity - 1, }), ); } }} /> ))} navigation.goBack()} > + Add more items {/* Coupon logic removed/commented out for now as requested Apply Coupon ... */} 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} /> ); };