enh
This commit is contained in:
parent
8fe3e4a301
commit
e546c52c05
1 changed files with 14 additions and 1 deletions
|
|
@ -14,6 +14,7 @@ import { useProductSlotIdentifier } from '@/hooks/useProductSlotIdentifier';
|
||||||
import { useFlashNavigationStore } from '@/components/stores/flashNavigationStore';
|
import { useFlashNavigationStore } from '@/components/stores/flashNavigationStore';
|
||||||
import FloatingCartBar from './floating-cart-bar';
|
import FloatingCartBar from './floating-cart-bar';
|
||||||
import { useStoreHeaderStore } from '@/src/store/storeHeaderStore';
|
import { useStoreHeaderStore } from '@/src/store/storeHeaderStore';
|
||||||
|
import { useCartStore } from '@/src/store/cartStore';
|
||||||
|
|
||||||
const { width: screenWidth } = Dimensions.get("window");
|
const { width: screenWidth } = Dimensions.get("window");
|
||||||
const carouselWidth = screenWidth;
|
const carouselWidth = screenWidth;
|
||||||
|
|
@ -55,6 +56,7 @@ const ProductDetail: React.FC<ProductDetailProps> = ({ productId, isFlashDeliver
|
||||||
const removeFromCart = useRemoveFromCart({ showSuccessAlert: false, showErrorAlert: false, refetchCart: true }, cartType);
|
const removeFromCart = useRemoveFromCart({ showSuccessAlert: false, showErrorAlert: false, refetchCart: true }, cartType);
|
||||||
const { getQuickestSlot } = useProductSlotIdentifier();
|
const { getQuickestSlot } = useProductSlotIdentifier();
|
||||||
const { setShouldNavigateToCart } = useFlashNavigationStore();
|
const { setShouldNavigateToCart } = useFlashNavigationStore();
|
||||||
|
const { setAddedToCartProduct } = useCartStore();
|
||||||
|
|
||||||
const sortedDeliverySlots = useMemo(() => {
|
const sortedDeliverySlots = useMemo(() => {
|
||||||
if (!productDetail?.deliverySlots) return []
|
if (!productDetail?.deliverySlots) return []
|
||||||
|
|
@ -305,7 +307,18 @@ const ProductDetail: React.FC<ProductDetailProps> = ({ productId, isFlashDeliver
|
||||||
borderColor: (productDetail.isOutOfStock || (isFlashDelivery && !productDetail.isFlashAvailable)) ? '#9ca3af' : theme.colors.brand500,
|
borderColor: (productDetail.isOutOfStock || (isFlashDelivery && !productDetail.isFlashAvailable)) ? '#9ca3af' : theme.colors.brand500,
|
||||||
backgroundColor: 'white'
|
backgroundColor: 'white'
|
||||||
}]}
|
}]}
|
||||||
onPress={() => !(productDetail.isOutOfStock || (isFlashDelivery && !productDetail.isFlashAvailable)) && handleAddToCart(productDetail.id)}
|
onPress={() => {
|
||||||
|
if (productDetail.isOutOfStock || (isFlashDelivery && !productDetail.isFlashAvailable)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isFlashDelivery) {
|
||||||
|
// Flash delivery: direct add
|
||||||
|
handleAddToCart(productDetail.id);
|
||||||
|
} else {
|
||||||
|
// Regular delivery: use dialog
|
||||||
|
setAddedToCartProduct({ productId: productDetail.id, product: productDetail });
|
||||||
|
}
|
||||||
|
}}
|
||||||
disabled={productDetail.isOutOfStock || (isFlashDelivery && !productDetail.isFlashAvailable)}
|
disabled={productDetail.isOutOfStock || (isFlashDelivery && !productDetail.isFlashAvailable)}
|
||||||
>
|
>
|
||||||
<MyText style={[tw`font-bold text-base`, { color: (productDetail.isOutOfStock || (isFlashDelivery && !productDetail.isFlashAvailable)) ? '#9ca3af' : theme.colors.brand500 }]}>
|
<MyText style={[tw`font-bold text-base`, { color: (productDetail.isOutOfStock || (isFlashDelivery && !productDetail.isFlashAvailable)) ? '#9ca3af' : theme.colors.brand500 }]}>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue