From ba1465372178d691b83e5533348e12742382ed54 Mon Sep 17 00:00:00 2001 From: shafi54 <108669266+shafi-aviz@users.noreply.github.com> Date: Sun, 24 May 2026 15:24:39 +0530 Subject: [PATCH] enh --- .../app/(drawer)/(tabs)/home/index.tsx | 39 ++++++++++--------- .../(drawer)/(tabs)/me/my-orders/index.tsx | 3 ++ .../src/components/AddToCartDialog.tsx | 2 +- apps/web-ui/src/routes/home.index.tsx | 12 +++--- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/apps/user-ui/app/(drawer)/(tabs)/home/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/home/index.tsx index 3d3e034..bd26514 100755 --- a/apps/user-ui/app/(drawer)/(tabs)/home/index.tsx +++ b/apps/user-ui/app/(drawer)/(tabs)/home/index.tsx @@ -389,25 +389,28 @@ export default function Dashboard() { React.useEffect(() => { - if (products.length > 0 && displayedProducts.length === 0) { - const initialBatch = products - .filter(p => typeof p.id === "number") - .sort((a, b) => { - const slotA = getQuickestSlot(a.id); - const slotB = getQuickestSlot(b.id); - if (slotA && !slotB) return -1; - if (!slotA && slotB) return 1; - const aOutOfStock = productSlotsMap[a.id]?.isOutOfStock; - const bOutOfStock = productSlotsMap[b.id]?.isOutOfStock; - if (aOutOfStock && !bOutOfStock) return 1; - if (!aOutOfStock && bOutOfStock) return -1; - return 0; - }); - - console.log('setting the displayed products') - setDisplayedProducts(initialBatch); - setHasMore(products.length > 10); + if (products.length === 0) { + setDisplayedProducts([]) + setHasMore(false) + return } + + const initialBatch = products + .filter(p => typeof p.id === "number") + .sort((a, b) => { + const slotA = getQuickestSlot(a.id) + const slotB = getQuickestSlot(b.id) + + const aOutOfStock = Boolean(productSlotsMap[a.id]?.isOutOfStock) || !slotA + const bOutOfStock = Boolean(productSlotsMap[b.id]?.isOutOfStock) || !slotB + + if (aOutOfStock && !bOutOfStock) return 1 + if (!aOutOfStock && bOutOfStock) return -1 + return 0 + }) + + setDisplayedProducts(initialBatch) + setHasMore(products.length > 10) }, [productsData, productSlotsMap]); const popularItemIds = useMemo(() => { diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/my-orders/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/my-orders/index.tsx index 805b5fd..119b25c 100755 --- a/apps/user-ui/app/(drawer)/(tabs)/me/my-orders/index.tsx +++ b/apps/user-ui/app/(drawer)/(tabs)/me/my-orders/index.tsx @@ -6,6 +6,9 @@ import { useRouter } from 'expo-router'; import { tw, useManualRefresh, MyText, MyFlatList, useMarkDataFetchers, REFUND_STATUS, MyTouchableOpacity, theme } from 'common-ui'; import { trpc } from '@/src/trpc-client'; +import { orderStatusManipulator } from '@/src/lib/string-manipulators'; +import dayjs from 'dayjs'; +import OrderMenu from '@/components/OrderMenu'; // Type definitions interface OrderItem { diff --git a/apps/user-ui/src/components/AddToCartDialog.tsx b/apps/user-ui/src/components/AddToCartDialog.tsx index 6384c68..9d72357 100644 --- a/apps/user-ui/src/components/AddToCartDialog.tsx +++ b/apps/user-ui/src/components/AddToCartDialog.tsx @@ -106,7 +106,7 @@ export default function AddToCartDialog() { const availableSlots = availableSlotIds .map((slotId) => slotMap[slotId]) .filter(Boolean) - .filter((slot) => dayjs(slot.deliveryTime).isAfter(dayjs())); + .filter((slot) => dayjs(slot.freezeTime).isAfter(dayjs())); // Find cart item for this product const cartItem = cartData?.items?.find((item: any) => item.productId === product?.id); diff --git a/apps/web-ui/src/routes/home.index.tsx b/apps/web-ui/src/routes/home.index.tsx index e781a13..e2885ee 100644 --- a/apps/web-ui/src/routes/home.index.tsx +++ b/apps/web-ui/src/routes/home.index.tsx @@ -124,15 +124,15 @@ function HomePage() { .sort((a, b) => { const slotA = getQuickestSlot(a.id) const slotB = getQuickestSlot(b.id) - if (slotA && !slotB) return -1 - if (!slotA && slotB) return 1 - const aOutOfStock = productSlotsMap[a.id]?.isOutOfStock - const bOutOfStock = productSlotsMap[b.id]?.isOutOfStock + + const aOutOfStock = Boolean(productSlotsMap[a.id]?.isOutOfStock) || !slotA + const bOutOfStock = Boolean(productSlotsMap[b.id]?.isOutOfStock) || !slotB + if (aOutOfStock && !bOutOfStock) return 1 if (!aOutOfStock && bOutOfStock) return -1 return 0 }) - }, [allProducts, productSlotsMap, getQuickestSlot]) + }, [productsData, productSlotsMap]) // Get popular products from essential consts const popularItemIds = useMemo(() => { @@ -537,4 +537,4 @@ function SlotCard({ slot }: { slot: any }) { ) -} \ No newline at end of file +}