import { View, Text, ScrollView, Image, Pressable} from 'react-native' import React from 'react' import { useStore } from '../store/store'; import PaymentFooter from '../components/PaymentFooter'; import CartItem from '../components/CartItem'; const Cart = ({navigation, route}: any) => { const CartList = useStore((state: any) => state.CartList); const CartPrice = useStore((state: any) => state.CartPrice); const addCartItemQuantity = useStore((state: any) => state.addCartItemQuantity); const removeCartItemQuantity = useStore((state: any) => state.removeCartItemQuantity); const calculateCartPrice = useStore((state: any) => state.calculateCartPrice); //console.log("CartList =", CartList.length) const buttonPressHandler = () => { navigation.push('payment', {amount: CartPrice}); } //add to cart functionality const addCartItemQuantityHandler = (id: string, size: string) => { addCartItemQuantity(id, size); calculateCartPrice(); }; //remove from cart functionality const removeCartItemQuantityHandler = (id: string, size: string) => { removeCartItemQuantity(id, size); calculateCartPrice(); }; return ( Cart {CartList.length == 0 ? ( Your cart is empty! ):( {CartList.map((data: any)=> ( { navigation.push('detail', {index: data.index, id:data.id, type: data.type}) }}> ))} )} {CartList.length != 0 ? ( ) : ( <> )} ) } export default Cart