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 FloatingCartBar from './floating-cart-bar';
|
||||
import { useStoreHeaderStore } from '@/src/store/storeHeaderStore';
|
||||
import { useCartStore } from '@/src/store/cartStore';
|
||||
|
||||
const { width: screenWidth } = Dimensions.get("window");
|
||||
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 { getQuickestSlot } = useProductSlotIdentifier();
|
||||
const { setShouldNavigateToCart } = useFlashNavigationStore();
|
||||
const { setAddedToCartProduct } = useCartStore();
|
||||
|
||||
const sortedDeliverySlots = useMemo(() => {
|
||||
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,
|
||||
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)}
|
||||
>
|
||||
<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