import { View, Text, ScrollView } from 'react-native'; import React, { useState } from 'react'; import { useStore } from '../store/store'; import { StatusBar } from 'expo-status-bar'; import BackgroundInfo from "../components/BackgroundInfo"; import PaymentFooter from "../components/PaymentFooter"; import { TouchableWithoutFeedback } from 'react-native-gesture-handler'; const Detail = ({navigation, route}: any) => { const ItemOfIndex = useStore((state: any) => route.params.type == 'Donut' ? state.AllDonutMenu : state.AllDrinkMenu, )[route.params.index]; const addToFavoriteList = useStore((state: any) => state.addToFavoriteList); const deleteFromFavoriteList = useStore((state: any) => state.deleteFromFavoriteList); //favorite functionality const ToggleFavorite = (favourite: boolean, type: string, id: string) => { favourite ? deleteFromFavoriteList(type, id) : addToFavoriteList(type, id) } //add to cart const addToCart = useStore((state: any) => state.addToCart); const calculateCartPrice = useStore((state: any) => state.calculateCartPrice); const addtoCartHandler = ({ id, index, donutname, image_item, type, price }: any) => { addToCart({ id, index, donutname, image_item, type, prices:[{...price, quantity:1}], }) calculateCartPrice(); navigation.navigate('cart'); } //backhandler functionality const BackHandler = () => { navigation.pop(); } //desc const [descriptionDrink, setDescriptionDrink] = useState(false); //set prices const [price, setPrice] = useState(ItemOfIndex.prices[0]); return ( {descriptionDrink? ( {setDescriptionDrink(prev => !prev)}}> {ItemOfIndex.description} ) : ( {setDescriptionDrink(prev => !prev)}}> {ItemOfIndex.description} )} { addtoCartHandler({ id: ItemOfIndex.id, index: ItemOfIndex.index, donutname: ItemOfIndex.donutname, image_item: ItemOfIndex.image_item, type: ItemOfIndex.type, price: price, }) }} /> ) } export default Detail