diff --git a/apps/user-ui/components/CheckoutAddressSelector.tsx b/apps/user-ui/components/CheckoutAddressSelector.tsx index 14e3983..ec3975c 100644 --- a/apps/user-ui/components/CheckoutAddressSelector.tsx +++ b/apps/user-ui/components/CheckoutAddressSelector.tsx @@ -1,7 +1,7 @@ import React, { useState, useEffect, useRef } from 'react'; import { View, Text, TouchableOpacity, ScrollView, Alert, NativeSyntheticEvent, NativeScrollEvent } from 'react-native'; import { useRouter } from 'expo-router'; -import { tw, BottomDialog, RawBottomDialog } from 'common-ui'; +import { tw, BottomDialog, RawBottomDialog, MyText } from 'common-ui'; import { useQueryClient } from '@tanstack/react-query'; import AddressForm from '@/src/components/AddressForm'; import LocationAttacher from '@/src/components/LocationAttacher'; @@ -263,15 +263,20 @@ const CheckoutAddressSelector: React.FC = ({ {selectedAddress && (() => { const selectedAddr = sortedAddresses.find(a => a.id === selectedAddress); return selectedAddr && !selectedAddr.latitude && !selectedAddr.longitude ? ( - handleAttachLocation(selectedAddr)} - disabled={locationLoading && editingLocationAddressId === selectedAddr.id} - style={tw`mt-3 py-2 px-3 bg-blue-50 rounded-lg self-start`} - > - - {locationLoading && editingLocationAddressId === selectedAddr.id ? 'Attaching...' : '+ Attach Current Location'} - - + <> + + No Location is attached to address + + handleAttachLocation(selectedAddr)} + disabled={locationLoading && editingLocationAddressId === selectedAddr.id} + style={tw`mt-2 py-2 px-3 bg-blue-50 rounded-lg self-start`} + > + + {locationLoading && editingLocationAddressId === selectedAddr.id ? 'Attaching...' : '+ Attach Current Location'} + + + ) : null; })()} diff --git a/apps/user-ui/components/PaymentAndOrderComponent.tsx b/apps/user-ui/components/PaymentAndOrderComponent.tsx index ca8e659..a8435d5 100644 --- a/apps/user-ui/components/PaymentAndOrderComponent.tsx +++ b/apps/user-ui/components/PaymentAndOrderComponent.tsx @@ -1,12 +1,13 @@ import React, { useState, useMemo } from 'react'; import { View, Alert, Platform } from 'react-native'; import { useRouter } from 'expo-router'; -import { tw, MyTextInput, LoadingDialog, MyText, MyTouchableOpacity } from 'common-ui'; +import { tw, LoadingDialog, MyText, MyTouchableOpacity } from 'common-ui'; import MaterialIcons from '@expo/vector-icons/MaterialIcons'; import { trpc } from '@/src/trpc-client'; import { useCentralProductStore } from '@/src/store/centralProductStore'; import { useCentralSlotStore } from '@/src/store/centralSlotStore'; import { useRegion } from '@/src/hooks/useRegion'; +import { useCheckoutStore } from '@/src/store/checkoutStore'; import { clearLocalCart } from '@/hooks/cart-query-hooks'; import { useQueryClient } from '@tanstack/react-query'; import { FontAwesome5, FontAwesome6 } from '@expo/vector-icons'; @@ -48,9 +49,9 @@ const PaymentAndOrderComponent: React.FC = ({ const router = useRouter(); const queryClient = useQueryClient(); const utils = trpc.useUtils(); - const [userNotes, setUserNotes] = useState(''); const [isLoadingDialogOpen, setIsLoadingDialogOpen] = useState(false); const [paymentMethod, setPaymentMethod] = useState<'online' | 'cod'>('cod'); + const userNotes = useCheckoutStore((state) => state.userNotes); // Helper function to clear cart and invalidate queries const clearCartAndInvalidateQueries = async (cartType: 'regular' | 'flash' = 'regular') => { @@ -194,20 +195,6 @@ const PaymentAndOrderComponent: React.FC = ({ )} - {/* Special Instructions */} - - Delivery Instructions - - - {/* Payment Method */} Payment Method @@ -357,6 +344,14 @@ const PaymentAndOrderComponent: React.FC = ({ )} + router.back()} + > + Back to Cart + + { @@ -185,6 +187,8 @@ export default function CartPage({ isFlashDelivery = false }: FlashDeliveryProps const cartType: "regular" | "flash" = isFlashDelivery ? "flash" : "regular"; const { selectedAddressId, setSelectedAddressId } = useAddressStore(); + const userNotes = useCheckoutStore((state) => state.userNotes); + const setUserNotes = useCheckoutStore((state) => state.setUserNotes); const [quantities, setQuantities] = useState>({}); const { @@ -979,10 +983,14 @@ export default function CartPage({ isFlashDelivery = false }: FlashDeliveryProps })} - + {/* Delivery Slot Summary */} + {!isFlashDelivery && cartItems.length > 0 && ( + + )} )} @@ -1113,14 +1121,23 @@ export default function CartPage({ isFlashDelivery = false }: FlashDeliveryProps )} - {/* Delivery Slot Summary */} - {!isFlashDelivery && cartItems.length > 0 && ( - + Delivery Instructions + - )} + + + {/* Delivery Address */} + {/* Bottom Checkout Bar - Now Static */} {hasAvailableItems && ( diff --git a/apps/user-ui/components/checkout-page.tsx b/apps/user-ui/components/checkout-page.tsx index 90f483e..66d308d 100644 --- a/apps/user-ui/components/checkout-page.tsx +++ b/apps/user-ui/components/checkout-page.tsx @@ -1,6 +1,7 @@ import React, { useState, useMemo } from 'react'; import { View, ScrollView } from 'react-native'; import { useLocalSearchParams, useRouter } from 'expo-router'; +import dayjs from 'dayjs'; import { tw, useMarkDataFetchers , BottomDialog, MyText, MyTouchableOpacity } from 'common-ui'; import MaterialIcons from '@expo/vector-icons/MaterialIcons'; import { useAuthenticatedRoute } from '@/hooks/useAuthenticatedRoute'; @@ -89,6 +90,37 @@ const CheckoutPage: React.FC = ({ isFlashDelivery = false }) return selectedSlots[item.id]; }); + // Read-only items grouped by their chosen delivery slot, sorted by slot time. + const groupedItems = useMemo(() => { + if (isFlashDelivery) { + return [ + { slotId: null as number | null, label: null as string | null, sortKey: 0, items: selectedItems }, + ]; + } + const groups = new Map(); + selectedItems.forEach((item) => { + const slotId = selectedSlots[item.id]; + if (slotId == null) return; + const list = groups.get(slotId) ?? []; + list.push(item); + groups.set(slotId, list); + }); + return Array.from(groups.entries()) + .map(([slotId, items]) => { + const slot = slotsData?.slots?.find((candidate) => candidate.id === slotId); + const deliveryTime = slot ? dayjs(slot.deliveryTime) : null; + return { + slotId: slotId as number | null, + label: (deliveryTime + ? deliveryTime.format('ddd, DD MMM h:mm A') + : `Slot #${slotId}`) as string | null, + sortKey: deliveryTime ? deliveryTime.valueOf() : Number.MAX_SAFE_INTEGER, + items, + }; + }) + .sort((a, b) => a.sortKey - b.sortKey); + }, [isFlashDelivery, selectedItems, selectedSlots, slotsData]); + React.useEffect(() => { if (params.coupons) { const couponId = Number(params.coupons as string); @@ -257,6 +289,69 @@ const CheckoutPage: React.FC = ({ isFlashDelivery = false }) contentContainerStyle={tw`p-4 pb-32`} showsVerticalScrollIndicator={false} > + {/* Items (grouped by delivery slot) */} + + Items + {groupedItems.map((group) => ( + + {group.label && ( + + + + {group.label} + + + )} + {group.items.map((item) => { + const product = productsById[item.skuId]; + const price = isFlashDelivery + ? (product?.flashPrice ?? product?.price ?? 0) + : (product?.price || 0); + return ( + + + + {product?.name} + + {!!product?.unitNotation && ( + + {product.unitNotation} + + )} + + x{item.quantity} + + ₹{Number(price) * item.quantity} + + + ); + })} + + ))} + + + {/* Coupon */} + {selectedCoupons.length > 0 && ( + + Coupon + {selectedCoupons.map((coupon) => ( + + {coupon.code} + + {coupon.discountType === 'percentage' + ? `${coupon.discountValue}% off` + : `₹${coupon.discountValue} off`} + + + ))} + + )} + void +} + +export const useCheckoutStore = create((set) => ({ + userNotes: '', + setUserNotes: (userNotes) => set({ userNotes }), +})) diff --git a/change-log.txt b/change-log.txt index e2a5f62..8bb3f3f 100644 --- a/change-log.txt +++ b/change-log.txt @@ -1302,3 +1302,30 @@ user-ui [2026-10-09 12:10:00] user-ui cart: address selector moved below the items; "Go to 1 Hr Delivery" switcher card hidden ({false && ...}). user-ui typecheck clean. + +[2026-10-09 12:20:00] user-ui CheckoutAddressSelector: show "No Location is attached to address" above the + Attach Current Location button when the selected address has no coordinates. + +[2026-10-09 12:30:00] user-ui cart: move the address selector to just above the Bill Details section. + +[2026-10-09 12:45:00] user-ui: instructions move to the cart; checkout becomes a read-only summary. + - new src/store/checkoutStore.ts (userNotes) shared between cart + checkout. + - cart-page: "Delivery Instructions" input above the address selector (bound to checkoutStore). + - PaymentAndOrderComponent: read userNotes from the store; remove its inline instructions input. + - checkout-page: read-only summary cards for Items, Delivery Slot, Coupon (address + bill already shown). + +[2026-10-09 12:55:00] done. user-ui typecheck clean. + - checkoutStore (userNotes); cart has the Delivery Instructions input above the address selector; + PaymentAndOrderComponent reads userNotes from the store (input removed) and still sends it with the order. + - checkout-page shows read-only Items / Delivery Slot / Coupon cards + address + bill. + +[2026-10-09 13:05:00] user-ui cart: move the Delivery Slot Summary to right after the items (before coupons). + (Checkout page already shows Items -> Delivery Slot -> Coupon -> Address -> Bill.) typecheck clean. + +[2026-10-09 13:15:00] user-ui checkout: Items section now groups by delivery slot (slot time header, then its + items), slots sorted by time; removed the separate Delivery Slot card. typecheck clean. + +[2026-10-09 13:20:00] user-ui checkout: give the slot-time header a subtle spotlight (pill background, + brand icon, semibold text). + +[2026-10-09 13:30:00] user-ui checkout: add a "Back to Cart" button above the Place Order button.