Compare commits
No commits in common. "286943c081a119124045c90898c38228c6767c95" and "90fc7ef6a7c6c6f5feeed364e65b422eaf8ee09e" have entirely different histories.
286943c081
...
90fc7ef6a7
21 changed files with 100 additions and 615 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## Important instructions
|
## Important instructions
|
||||||
- Don't run any drizzle migrations. User will handle it.
|
- Don't run any drizzle migrations. User will handle it.
|
||||||
- don't try to run any test from the suite unless user explicitly asks for
|
- don't try to run any test unless user explicitly asks for
|
||||||
|
|
||||||
## Code Style Guidelines
|
## Code Style Guidelines
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ export default function Dashboard() {
|
||||||
|
|
||||||
const menuItems: MenuItem[] = [
|
const menuItems: MenuItem[] = [
|
||||||
{
|
{
|
||||||
title: 'Manage Orders',
|
title: 'Manage Orderss',
|
||||||
icon: 'shopping-bag',
|
icon: 'shopping-bag',
|
||||||
description: 'View and manage customer orders',
|
description: 'View and manage customer orders',
|
||||||
route: '/(drawer)/dashboard/manage-orders',
|
route: '/(drawer)/dashboard/manage-orders',
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { createTRPCProxyClient, httpBatchLink, TRPCClientError } from '@trpc/client';
|
import { createTRPCProxyClient, httpBatchLink, TRPCClientError } from '@trpc/client';
|
||||||
import { createTRPCReact } from '@trpc/react-query';
|
import { createTRPCReact } from '@trpc/react-query';
|
||||||
import { AppRouter } from '@backend/trpc/router'
|
import { AppRouter } from '@backend/trpc/router'
|
||||||
import { BASE_API_URL } from '@packages/shared';
|
import { BASE_API_URL } from 'common-ui';
|
||||||
import { getJWT } from '@/hooks/useJWT';
|
import { getJWT } from '@/hooks/useJWT';
|
||||||
import { FORCE_LOGOUT_EVENT } from 'common-ui/src/lib/const-strs';
|
import { FORCE_LOGOUT_EVENT } from 'common-ui/src/lib/const-strs';
|
||||||
import { DeviceEventEmitter } from 'react-native';
|
import { DeviceEventEmitter } from 'react-native';
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,11 @@ import { createTRPCClient, httpBatchLink } from '@trpc/client'
|
||||||
import type { AppRouter } from '@backend/trpc/router'
|
import type { AppRouter } from '@backend/trpc/router'
|
||||||
import { getJWT } from '../hooks/useJWT'
|
import { getJWT } from '../hooks/useJWT'
|
||||||
import { EventBus, FORCE_LOGOUT_EVENT } from './event-bus'
|
import { EventBus, FORCE_LOGOUT_EVENT } from './event-bus'
|
||||||
import { BASE_API_URL as DEFAULT_API_URL } from '@packages/shared'
|
|
||||||
|
|
||||||
// Same backend as admin-ui; overridable via VITE_API_URL (set it to
|
// Same backend as admin-ui (BASE_API_URL from common-ui); overridable via env.
|
||||||
// https://devapi.freshyo.in for dev builds — the shared default is production).
|
|
||||||
export const BASE_API_URL =
|
export const BASE_API_URL =
|
||||||
(import.meta.env?.VITE_API_URL as string | undefined) || DEFAULT_API_URL
|
// (import.meta.env?.VITE_API_URL as string | undefined) || 'https://worker.freshyo.in'
|
||||||
|
(import.meta.env?.VITE_API_URL as string | undefined) || 'https://devapi.freshyo.in'
|
||||||
|
|
||||||
export const trpc = createTRPCReact<AppRouter>()
|
export const trpc = createTRPCReact<AppRouter>()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { BASE_API_URL } from '@packages/shared'
|
|
||||||
|
|
||||||
const webUiConstants = {
|
const webUiConstants = {
|
||||||
baseUrl: `${BASE_API_URL}/`
|
baseUrl: 'https://worker.freshyo.in/'
|
||||||
|
// baseUrl: '/'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ export default defineConfig({
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': path.resolve(__dirname, 'src'),
|
'@': path.resolve(__dirname, 'src'),
|
||||||
'@packages/shared': path.resolve(__dirname, '../../packages/shared'),
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
import { createTRPCReact } from '@trpc/react-query'
|
import { createTRPCReact } from '@trpc/react-query'
|
||||||
import { createTRPCClient, httpBatchLink } from '@trpc/client'
|
import { createTRPCClient, httpBatchLink } from '@trpc/client'
|
||||||
import type { AppRouter } from '@backend/trpc/router'
|
import type { AppRouter } from '@backend/trpc/router'
|
||||||
import { BASE_API_URL as DEFAULT_API_URL } from '@packages/shared'
|
|
||||||
|
|
||||||
// const BASE_API_URL = 'http://192.168.100.126:8787'
|
// const BASE_API_URL = 'http://192.168.100.126:8787'
|
||||||
export const BASE_API_URL =
|
export const BASE_API_URL =
|
||||||
(import.meta.env?.VITE_API_URL as string | undefined) || DEFAULT_API_URL
|
(import.meta.env?.VITE_API_URL as string | undefined) || 'https://worker.freshyo.in'
|
||||||
|
|
||||||
export const trpc = createTRPCReact<AppRouter>()
|
export const trpc = createTRPCReact<AppRouter>()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -391,9 +391,6 @@ const ListHeader = memo(({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View style={tw`pt-2`}>
|
|
||||||
<NextOrderGlimpse />
|
|
||||||
</View>
|
|
||||||
{dashboardTags.length > 0 && (
|
{dashboardTags.length > 0 && (
|
||||||
<TagTabStrip
|
<TagTabStrip
|
||||||
dashboardTags={dashboardTags}
|
dashboardTags={dashboardTags}
|
||||||
|
|
@ -446,6 +443,10 @@ const ListHeader = memo(({
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<View style={tw`py-2`}>
|
||||||
|
<NextOrderGlimpse />
|
||||||
|
</View>
|
||||||
|
|
||||||
{sortedSlots.length > 0 && (
|
{sortedSlots.length > 0 && (
|
||||||
<View style={tw`mt-2 mb-4`}>
|
<View style={tw`mt-2 mb-4`}>
|
||||||
<View style={tw`flex-row items-center justify-between px-1 mb-6`}>
|
<View style={tw`flex-row items-center justify-between px-1 mb-6`}>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import ComplaintForm from "@/components/ComplaintForm";
|
import ComplaintForm from "@/components/ComplaintForm";
|
||||||
import { orderStatusManipulator } from "@/src/lib/string-manipulators";
|
import { orderStatusManipulator } from "@/src/lib/string-manipulators";
|
||||||
import OrderStatusTracker from "@/components/OrderStatusTracker";
|
|
||||||
|
|
||||||
export default function OrderDetails() {
|
export default function OrderDetails() {
|
||||||
const { id } = useLocalSearchParams<{ id: string }>();
|
const { id } = useLocalSearchParams<{ id: string }>();
|
||||||
|
|
@ -177,12 +176,6 @@ export default function OrderDetails() {
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Order Status Tracker */}
|
|
||||||
<View style={tw`bg-white rounded-2xl p-5 mb-4 border border-slate-100`}>
|
|
||||||
<MyText style={tw`text-slate-400 text-[10px] font-bold uppercase mb-4`}>Order Status</MyText>
|
|
||||||
<OrderStatusTracker deliveryStatus={order.deliveryStatus} />
|
|
||||||
</View>
|
|
||||||
|
|
||||||
{/* Main Info Card */}
|
{/* Main Info Card */}
|
||||||
<View style={tw`bg-white rounded-2xl p-5 mb-4 border border-slate-100`}>
|
<View style={tw`bg-white rounded-2xl p-5 mb-4 border border-slate-100`}>
|
||||||
<View style={tw`flex-row items-center justify-between mb-4`}>
|
<View style={tw`flex-row items-center justify-between mb-4`}>
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ import { View, TouchableOpacity, ActivityIndicator, Linking, ScrollView, Dimensi
|
||||||
import { useRouter } from 'expo-router';
|
import { useRouter } from 'expo-router';
|
||||||
import { tw, MyText } from 'common-ui';
|
import { tw, MyText } from 'common-ui';
|
||||||
import { useNavigationTarget } from 'common-ui/hooks/useNavigationTarget';
|
import { useNavigationTarget } from 'common-ui/hooks/useNavigationTarget';
|
||||||
import { MaterialIcons } from '@expo/vector-icons';
|
import { MaterialIcons, Ionicons } from '@expo/vector-icons';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { trpc } from '@/src/trpc-client';
|
import { trpc } from '@/src/trpc-client';
|
||||||
|
import { Image } from 'expo-image';
|
||||||
import { orderStatusManipulator } from '@/src/lib/string-manipulators';
|
import { orderStatusManipulator } from '@/src/lib/string-manipulators';
|
||||||
import OrderStatusTracker from './OrderStatusTracker';
|
|
||||||
import { useGetEssentialConsts } from '@/src/hooks/prominent-api-hooks';
|
import { useGetEssentialConsts } from '@/src/hooks/prominent-api-hooks';
|
||||||
import { useUserDetails } from '@/src/contexts/AuthContext';
|
import { useUserDetails } from '@/src/contexts/AuthContext';
|
||||||
import type { Order, OrderItem } from '@/src/types/orders';
|
import type { Order, OrderItem } from '@/src/types/orders';
|
||||||
|
|
@ -22,22 +22,6 @@ interface OrderCardProps extends OrderCardActionProps<Order> {
|
||||||
}
|
}
|
||||||
|
|
||||||
function OrderCard({ order, onPress, supportMobile }: OrderCardProps) {
|
function OrderCard({ order, onPress, supportMobile }: OrderCardProps) {
|
||||||
const statusLabel = orderStatusManipulator(order.deliveryStatus);
|
|
||||||
const hideStatus = ['confirmed', 'packaged'].includes(statusLabel.toLowerCase());
|
|
||||||
const deliveryPrimaryLabel = order.isFlashDelivery
|
|
||||||
? "30-Min"
|
|
||||||
: (() => {
|
|
||||||
const startTime = dayjs(order.deliveryDate);
|
|
||||||
const endTime = startTime.add(1, 'hour');
|
|
||||||
const startPeriod = startTime.format("A");
|
|
||||||
const endPeriod = endTime.format("A");
|
|
||||||
return startPeriod === endPeriod
|
|
||||||
? `${startTime.format("hh:mm")} - ${endTime.format("hh:mm")} ${startPeriod}`
|
|
||||||
: `${startTime.format("hh:mm A")} - ${endTime.format("hh:mm A")}`;
|
|
||||||
})();
|
|
||||||
const deliverySecondaryLabel = order.isFlashDelivery
|
|
||||||
? "Delivery"
|
|
||||||
: dayjs(order.deliveryDate).format("DD MMM");
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={{ width: CARD_WIDTH, marginRight: 24 }}
|
style={{ width: CARD_WIDTH, marginRight: 24 }}
|
||||||
|
|
@ -50,15 +34,12 @@ function OrderCard({ order, onPress, supportMobile }: OrderCardProps) {
|
||||||
<View style={tw`w-2 h-2 rounded-full bg-amber-500 mr-2`} />
|
<View style={tw`w-2 h-2 rounded-full bg-amber-500 mr-2`} />
|
||||||
<MyText style={tw`text-[10px] font-bold text-amber-600 uppercase tracking-wider`}>Upcoming Order</MyText>
|
<MyText style={tw`text-[10px] font-bold text-amber-600 uppercase tracking-wider`}>Upcoming Order</MyText>
|
||||||
</View>
|
</View>
|
||||||
<View style={tw`flex-row items-center`}>
|
{order.isFlashDelivery && (
|
||||||
{order.isFlashDelivery && (
|
<View style={tw`px-2 py-0.5 bg-amber-200 rounded-full flex-row items-center`}>
|
||||||
<View style={tw`px-2 py-0.5 bg-amber-200 rounded-full flex-row items-center mr-1.5`}>
|
<MaterialIcons name="bolt" size={10} color="#D97706" style={tw`mr-0.5`} />
|
||||||
<MaterialIcons name="bolt" size={10} color="#D97706" style={tw`mr-0.5`} />
|
<MyText style={tw`text-[8px] font-black text-amber-700 uppercase`}>FLASH</MyText>
|
||||||
<MyText style={tw`text-[8px] font-black text-amber-700 uppercase`}>FLASH</MyText>
|
</View>
|
||||||
</View>
|
)}
|
||||||
)}
|
|
||||||
<MaterialIcons name="chevron-right" size={18} color="#B45309" />
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={tw`flex-row justify-between items-start mb-3`}>
|
<View style={tw`flex-row justify-between items-start mb-3`}>
|
||||||
|
|
@ -68,35 +49,58 @@ function OrderCard({ order, onPress, supportMobile }: OrderCardProps) {
|
||||||
{order.items.length} {order.items.length === 1 ? 'item' : 'items'} • ₹{order.totalAmount}
|
{order.items.length} {order.items.length === 1 ? 'item' : 'items'} • ₹{order.totalAmount}
|
||||||
</MyText>
|
</MyText>
|
||||||
</View>
|
</View>
|
||||||
<View style={tw`items-end`}>
|
<View style={tw`bg-white px-2 py-1 rounded-lg border border-amber-200`}>
|
||||||
<View style={tw`bg-white px-2.5 py-1.5 rounded-2xl border border-amber-200 items-end`}>
|
<MyText style={tw`text-[10px] font-bold text-amber-700 uppercase`}>{orderStatusManipulator(order.deliveryStatus)}</MyText>
|
||||||
<View style={tw`flex-row items-center`}>
|
|
||||||
<MaterialIcons
|
|
||||||
name={order.isFlashDelivery ? "bolt" : "schedule"}
|
|
||||||
size={13}
|
|
||||||
color="#D97706"
|
|
||||||
style={tw`mr-1`}
|
|
||||||
/>
|
|
||||||
<MyText style={tw`text-[13px] font-black text-amber-900`}>{deliveryPrimaryLabel}</MyText>
|
|
||||||
</View>
|
|
||||||
<MyText style={tw`text-[9px] font-semibold text-amber-500 mt-0.5`}>{deliverySecondaryLabel}</MyText>
|
|
||||||
</View>
|
|
||||||
{!hideStatus && (
|
|
||||||
<View style={tw`bg-white px-2 py-0.5 rounded-lg border border-amber-200 mt-1`}>
|
|
||||||
<MyText style={tw`text-[10px] font-bold text-amber-700 uppercase`}>{statusLabel}</MyText>
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={tw`mt-3`}>
|
<View style={tw`flex-row items-center`}>
|
||||||
<OrderStatusTracker
|
<MaterialIcons
|
||||||
deliveryStatus={order.deliveryStatus}
|
name={order.isFlashDelivery ? "bolt" : "schedule"}
|
||||||
activeColor="#D97706"
|
size={14}
|
||||||
inactiveColor="#FDE68A"
|
color="#D97706"
|
||||||
|
style={tw`mr-1.5`}
|
||||||
/>
|
/>
|
||||||
|
<MyText style={tw`text-xs font-medium text-amber-800`}>
|
||||||
|
{order.isFlashDelivery
|
||||||
|
? "30-Min Delivery"
|
||||||
|
: (() => {
|
||||||
|
const startTime = dayjs(order.deliveryDate);
|
||||||
|
const endTime = startTime.add(1, 'hour');
|
||||||
|
return `${startTime.format("DD MMM, hh:mm A")} - ${endTime.format("hh:mm A")}`;
|
||||||
|
})()
|
||||||
|
}
|
||||||
|
</MyText>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
{order.items.length > 0 && (
|
||||||
|
<View style={tw`flex-row items-center mt-3 pt-3 border-t border-amber-200`}>
|
||||||
|
<View style={tw`flex-row`}>
|
||||||
|
{order.items.slice(0, 3).map((item, idx) => (
|
||||||
|
<View
|
||||||
|
key={idx}
|
||||||
|
style={[
|
||||||
|
tw`w-8 h-8 rounded-lg bg-white border border-amber-200 items-center justify-center`,
|
||||||
|
{ marginLeft: idx > 0 ? -8 : 0 }
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
source={{ uri: item.image || undefined }}
|
||||||
|
style={tw`w-full h-full rounded-lg`}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
|
{order.items.length > 3 && (
|
||||||
|
<View style={tw`w-8 h-8 rounded-lg bg-amber-100 border border-amber-200 items-center justify-center ml-2`}>
|
||||||
|
<MyText style={tw`text-[9px] font-bold text-amber-700`}>+{order.items.length - 3}</MyText>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
<MyText style={tw`text-xs text-amber-700 font-medium ml-2`}>Track Order</MyText>
|
||||||
|
<Ionicons name="chevron-forward" size={14} color="#D97706" style={tw`ml-auto`} />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Support Mobile Number */}
|
{/* Support Mobile Number */}
|
||||||
{supportMobile && (
|
{supportMobile && (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
|
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
||||||
import { View } from 'react-native';
|
|
||||||
import { tw, MyText } from 'common-ui';
|
|
||||||
|
|
||||||
const STAGES = ['Placed', 'Packed', 'Delivered'] as const;
|
|
||||||
|
|
||||||
export type OrderStage = (typeof STAGES)[number];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Maps a backend deliveryStatus to the furthest stage reached:
|
|
||||||
* pending / processing -> 0 (Placed)
|
|
||||||
* packaged -> 1 (Packed)
|
|
||||||
* success / delivered -> 2 (Delivered)
|
|
||||||
* Anything else (incl. cancelled) falls back to 0.
|
|
||||||
*/
|
|
||||||
export function deliveryStageIndex(deliveryStatus?: string | null): number {
|
|
||||||
switch ((deliveryStatus || '').toLowerCase()) {
|
|
||||||
case 'packaged':
|
|
||||||
return 1;
|
|
||||||
case 'success':
|
|
||||||
case 'delivered':
|
|
||||||
return 2;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OrderStatusTrackerProps {
|
|
||||||
deliveryStatus?: string | null;
|
|
||||||
activeColor?: string;
|
|
||||||
inactiveColor?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function OrderStatusTracker({
|
|
||||||
deliveryStatus,
|
|
||||||
activeColor = '#10B981',
|
|
||||||
inactiveColor = '#E2E8F0',
|
|
||||||
}: OrderStatusTrackerProps) {
|
|
||||||
const cancelled = (deliveryStatus || '').toLowerCase() === 'cancelled';
|
|
||||||
const currentIndex = cancelled ? -1 : deliveryStageIndex(deliveryStatus);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View testID="order-status-tracker" style={tw`flex-row`}>
|
|
||||||
{STAGES.map((label, i) => {
|
|
||||||
const reached = i <= currentIndex;
|
|
||||||
const dotColor = reached ? activeColor : inactiveColor;
|
|
||||||
const leftLine = i > 0 && i <= currentIndex ? activeColor : inactiveColor;
|
|
||||||
const rightLine = i < STAGES.length - 1 && i < currentIndex ? activeColor : inactiveColor;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View key={label} style={tw`flex-1 items-center`}>
|
|
||||||
<View style={tw`flex-row items-center w-full`}>
|
|
||||||
<View style={[tw`flex-1 h-0.5 rounded-full`, { backgroundColor: leftLine }]} />
|
|
||||||
<View
|
|
||||||
testID={`order-status-dot-${label.toLowerCase()}`}
|
|
||||||
style={[tw`w-3 h-3 rounded-full`, { backgroundColor: dotColor }]}
|
|
||||||
/>
|
|
||||||
<View style={[tw`flex-1 h-0.5 rounded-full`, { backgroundColor: rightLine }]} />
|
|
||||||
</View>
|
|
||||||
<MyText
|
|
||||||
style={[
|
|
||||||
tw`text-[9px] font-bold mt-1`,
|
|
||||||
{ color: reached && !cancelled ? activeColor : '#94A3B8' },
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
{label}
|
|
||||||
</MyText>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -30,167 +30,6 @@ import { useGetCart, useUpdateCartItem, useRemoveFromCart } from '@/hooks/cart-q
|
||||||
import { useGetEssentialConsts } from '@/src/hooks/prominent-api-hooks';
|
import { useGetEssentialConsts } from '@/src/hooks/prominent-api-hooks';
|
||||||
import type { FlashDeliveryProps } from '@packages/shared';
|
import type { FlashDeliveryProps } from '@packages/shared';
|
||||||
|
|
||||||
const formatDeliverySlot = (deliveryTime: string): string => {
|
|
||||||
const time = dayjs(deliveryTime);
|
|
||||||
const endTime = time.add(1, 'hour');
|
|
||||||
const startPeriod = time.format('A');
|
|
||||||
const endPeriod = endTime.format('A');
|
|
||||||
|
|
||||||
const range = startPeriod === endPeriod
|
|
||||||
? `${time.format('h')}-${endTime.format('h')} ${startPeriod}`
|
|
||||||
: `${time.format('h:mm')} ${startPeriod} - ${endTime.format('h:mm')} ${endPeriod}`;
|
|
||||||
|
|
||||||
return `${time.format('ddd, DD MMM ')}${range}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface DeliverySlotGroupItem {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
quantity: number;
|
|
||||||
unitNotation?: string;
|
|
||||||
image?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface DeliverySlotGroup {
|
|
||||||
slotId: number;
|
|
||||||
label: string;
|
|
||||||
items: DeliverySlotGroupItem[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface DeliverySlotMergeSuggestion {
|
|
||||||
slotId: number;
|
|
||||||
label: string;
|
|
||||||
feasible: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
function DeliverySlotSummary({
|
|
||||||
groups,
|
|
||||||
mergeSuggestion,
|
|
||||||
onMerge,
|
|
||||||
}: {
|
|
||||||
groups: DeliverySlotGroup[];
|
|
||||||
mergeSuggestion?: DeliverySlotMergeSuggestion | null;
|
|
||||||
onMerge?: () => void;
|
|
||||||
}) {
|
|
||||||
const [openGroup, setOpenGroup] = useState<DeliverySlotGroup | null>(null);
|
|
||||||
|
|
||||||
if (groups.length === 0) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View
|
|
||||||
testID="delivery-slot-summary"
|
|
||||||
style={tw`bg-white rounded-2xl shadow-sm mb-4 border border-gray-100 overflow-hidden`}
|
|
||||||
>
|
|
||||||
<View style={tw`bg-gray-50 px-4 py-3 border-b border-gray-100`}>
|
|
||||||
<MyText style={tw`text-gray-900 font-bold text-base`}>Delivery Slot</MyText>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<View style={tw`p-4`}>
|
|
||||||
{groups.map((group, index) => (
|
|
||||||
<View
|
|
||||||
key={group.slotId}
|
|
||||||
style={[
|
|
||||||
tw`flex-row items-center justify-between py-2.5`,
|
|
||||||
index > 0 ? tw`border-t border-gray-100` : {},
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<View style={tw`flex-row items-center flex-1 mr-3`}>
|
|
||||||
<MaterialIcons name="schedule" size={16} color="#6B7280" style={tw`mr-2`} />
|
|
||||||
<MyText style={tw`text-sm text-gray-700 flex-1`}>{group.label}</MyText>
|
|
||||||
</View>
|
|
||||||
<MyTouchableOpacity
|
|
||||||
testID={`delivery-slot-items-${group.slotId}`}
|
|
||||||
style={tw`flex-row items-center`}
|
|
||||||
onPress={() => setOpenGroup(group)}
|
|
||||||
activeOpacity={0.7}
|
|
||||||
>
|
|
||||||
<MyText style={tw`text-sm font-medium text-brand500`}>
|
|
||||||
{group.items.length} {group.items.length === 1 ? 'item' : 'items'}
|
|
||||||
</MyText>
|
|
||||||
<MaterialIcons name="chevron-right" size={18} color="#1570EF" />
|
|
||||||
</MyTouchableOpacity>
|
|
||||||
</View>
|
|
||||||
))}
|
|
||||||
|
|
||||||
{!!mergeSuggestion && (
|
|
||||||
<View
|
|
||||||
testID="delivery-slot-merge"
|
|
||||||
style={[
|
|
||||||
tw`mt-3 flex-row items-center justify-between rounded-xl px-3 py-2.5 border`,
|
|
||||||
mergeSuggestion.feasible
|
|
||||||
? tw`bg-brand50 border-brand200`
|
|
||||||
: tw`bg-gray-50 border-gray-200`,
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<View style={tw`flex-row items-center flex-1 mr-2`}>
|
|
||||||
<MaterialIcons
|
|
||||||
name="merge-type"
|
|
||||||
size={16}
|
|
||||||
color={mergeSuggestion.feasible ? '#1570EF' : '#9CA3AF'}
|
|
||||||
/>
|
|
||||||
<MyText
|
|
||||||
style={[
|
|
||||||
tw`text-sm ml-2 flex-1`,
|
|
||||||
mergeSuggestion.feasible ? tw`font-medium text-brand700` : tw`text-gray-500`,
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
Deliver All items at {mergeSuggestion.label}
|
|
||||||
</MyText>
|
|
||||||
</View>
|
|
||||||
{mergeSuggestion.feasible && (
|
|
||||||
<MyTouchableOpacity
|
|
||||||
testID="delivery-slot-merge-apply"
|
|
||||||
onPress={onMerge}
|
|
||||||
activeOpacity={0.7}
|
|
||||||
style={tw`p-1`}
|
|
||||||
>
|
|
||||||
<MaterialIcons name="chevron-right" size={20} color="#1570EF" />
|
|
||||||
</MyTouchableOpacity>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<BottomDialog open={!!openGroup} onClose={() => setOpenGroup(null)}>
|
|
||||||
<View style={tw`p-6`}>
|
|
||||||
<View style={tw`flex-row items-start justify-between mb-4`}>
|
|
||||||
<View style={tw`flex-1 mr-3`}>
|
|
||||||
<MyText style={tw`text-lg font-bold text-gray-900`}>Items</MyText>
|
|
||||||
<MyText style={tw`text-xs text-gray-500 mt-0.5`}>{openGroup?.label}</MyText>
|
|
||||||
</View>
|
|
||||||
<MyTouchableOpacity onPress={() => setOpenGroup(null)} style={tw`p-1`}>
|
|
||||||
<MaterialIcons name="close" size={22} color="#9CA3AF" />
|
|
||||||
</MyTouchableOpacity>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
{openGroup?.items.map((item) => (
|
|
||||||
<View
|
|
||||||
key={item.id}
|
|
||||||
style={tw`flex-row items-center py-3 border-b border-gray-50`}
|
|
||||||
>
|
|
||||||
<Image
|
|
||||||
source={{ uri: item.image }}
|
|
||||||
style={tw`w-10 h-10 rounded-lg bg-gray-100 mr-3`}
|
|
||||||
/>
|
|
||||||
<View style={tw`flex-1`}>
|
|
||||||
<MyText style={tw`text-sm text-gray-900`} numberOfLines={1}>
|
|
||||||
{item.name}
|
|
||||||
</MyText>
|
|
||||||
{!!item.unitNotation && (
|
|
||||||
<MyText style={tw`text-xs text-gray-500 mt-0.5`}>
|
|
||||||
{item.unitNotation}
|
|
||||||
</MyText>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
<MyText style={tw`text-sm font-bold text-gray-900`}>x{item.quantity}</MyText>
|
|
||||||
</View>
|
|
||||||
))}
|
|
||||||
</View>
|
|
||||||
</BottomDialog>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function CartPage({ isFlashDelivery = false }: FlashDeliveryProps) {
|
export default function CartPage({ isFlashDelivery = false }: FlashDeliveryProps) {
|
||||||
// Hide tabs when cart page is active
|
// Hide tabs when cart page is active
|
||||||
useHideTabNav();
|
useHideTabNav();
|
||||||
|
|
@ -458,82 +297,6 @@ export default function CartPage({ isFlashDelivery = false }: FlashDeliveryProps
|
||||||
|
|
||||||
const hasAvailableItems = cartItems.some(item => !productSlotsMap[item.skuId]?.isOutOfStock);
|
const hasAvailableItems = cartItems.some(item => !productSlotsMap[item.skuId]?.isOutOfStock);
|
||||||
|
|
||||||
const slotGroups = useMemo<DeliverySlotGroup[]>(() => {
|
|
||||||
if (isFlashDelivery || cartItems.length === 0) return [];
|
|
||||||
|
|
||||||
const groupMap = new Map<number, DeliverySlotGroup>();
|
|
||||||
|
|
||||||
cartItems.forEach((item) => {
|
|
||||||
const slotId = selectedSlots[item.id];
|
|
||||||
if (slotId === undefined || slotId === null) return;
|
|
||||||
|
|
||||||
if (!groupMap.has(slotId)) {
|
|
||||||
let label = '';
|
|
||||||
if (slotsData) {
|
|
||||||
for (const productId of Object.keys(slotsData)) {
|
|
||||||
const slot = slotsData[Number(productId)]?.find((s) => s.id === slotId);
|
|
||||||
if (slot) {
|
|
||||||
label = formatDeliverySlot(slot.deliveryTime);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
groupMap.set(slotId, { slotId, label, items: [] });
|
|
||||||
}
|
|
||||||
|
|
||||||
const product = productsById[item.skuId];
|
|
||||||
groupMap.get(slotId)!.items.push({
|
|
||||||
id: item.id,
|
|
||||||
name: product?.name || 'Item',
|
|
||||||
quantity: quantities[item.id] || item.quantity,
|
|
||||||
unitNotation: product?.unitNotation,
|
|
||||||
image: product?.images?.[0],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return Array.from(groupMap.values()).sort((a, b) => a.slotId - b.slotId);
|
|
||||||
}, [isFlashDelivery, cartItems, selectedSlots, slotsData, productsById, quantities]);
|
|
||||||
|
|
||||||
const mergeSuggestion = useMemo<DeliverySlotMergeSuggestion | null>(() => {
|
|
||||||
if (isFlashDelivery || slotGroups.length === 0) return null;
|
|
||||||
|
|
||||||
// slotGroups is sorted by slot id, so ties keep the lowest id.
|
|
||||||
const majority = slotGroups.reduce((best, group) =>
|
|
||||||
group.items.length > best.items.length ? group : best
|
|
||||||
);
|
|
||||||
|
|
||||||
const inStockItems = cartItems.filter(
|
|
||||||
(item) => !productSlotsMap[item.skuId]?.isOutOfStock
|
|
||||||
);
|
|
||||||
|
|
||||||
const now = dayjs();
|
|
||||||
const feasible =
|
|
||||||
slotGroups.length > 1 &&
|
|
||||||
inStockItems.length > 0 &&
|
|
||||||
inStockItems.every((item) =>
|
|
||||||
(slotsData?.[item.skuId] || []).some(
|
|
||||||
(slot) =>
|
|
||||||
slot.id === majority.slotId &&
|
|
||||||
dayjs(slot.deliveryTime).isAfter(now)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return { slotId: majority.slotId, label: majority.label, feasible };
|
|
||||||
}, [isFlashDelivery, slotGroups, cartItems, productSlotsMap, slotsData]);
|
|
||||||
|
|
||||||
const handleMergeSlots = () => {
|
|
||||||
if (!mergeSuggestion) return;
|
|
||||||
setSelectedSlots((prev) => {
|
|
||||||
const next = { ...prev };
|
|
||||||
cartItems.forEach((item) => {
|
|
||||||
if (!productSlotsMap[item.skuId]?.isOutOfStock) {
|
|
||||||
next[item.id] = mergeSuggestion.slotId;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return next;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const initial: Record<number, number> = {};
|
const initial: Record<number, number> = {};
|
||||||
cartItems.forEach((item) => {
|
cartItems.forEach((item) => {
|
||||||
|
|
@ -1100,15 +863,6 @@ export default function CartPage({ isFlashDelivery = false }: FlashDeliveryProps
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Delivery Slot Summary */}
|
|
||||||
{!isFlashDelivery && cartItems.length > 0 && (
|
|
||||||
<DeliverySlotSummary
|
|
||||||
groups={slotGroups}
|
|
||||||
mergeSuggestion={mergeSuggestion}
|
|
||||||
onMerge={handleMergeSlots}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Bottom Checkout Bar - Now Static */}
|
{/* Bottom Checkout Bar - Now Static */}
|
||||||
{hasAvailableItems && (
|
{hasAvailableItems && (
|
||||||
<View style={tw`bg-white mt-4 rounded-2xl shadow-sm border border-gray-100 overflow-hidden mb-6`}>
|
<View style={tw`bg-white mt-4 rounded-2xl shadow-sm border border-gray-100 overflow-hidden mb-6`}>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { createTRPCProxyClient, httpBatchLink } from "@trpc/client";
|
import { createTRPCProxyClient, httpBatchLink } from "@trpc/client";
|
||||||
import { createTRPCReact } from "@trpc/react-query";
|
import { createTRPCReact } from "@trpc/react-query";
|
||||||
import { AppRouter } from "@backend/trpc/router";
|
import { AppRouter } from "@backend/trpc/router";
|
||||||
import { BASE_API_URL } from "@packages/shared";
|
import { BASE_API_URL } from "common-ui";
|
||||||
import { getAuthToken } from "@/hooks/useJWT";
|
import { getAuthToken } from "@/hooks/useJWT";
|
||||||
import { DeviceEventEmitter } from "react-native";
|
import { DeviceEventEmitter } from "react-native";
|
||||||
import { FORCE_LOGOUT_EVENT } from "common-ui/src/lib/const-strs";
|
import { FORCE_LOGOUT_EVENT } from "common-ui/src/lib/const-strs";
|
||||||
|
|
|
||||||
|
|
@ -90,10 +90,8 @@ describe('NextOrderGlimpse', () => {
|
||||||
|
|
||||||
expect(screen.getByText('#ORD-1001')).toBeVisible()
|
expect(screen.getByText('#ORD-1001')).toBeVisible()
|
||||||
expect(screen.getByText('2 items • ₹500')).toBeVisible()
|
expect(screen.getByText('2 items • ₹500')).toBeVisible()
|
||||||
// The status pill is hidden for Confirmed/Packaged; the tracker shows the stage.
|
// deliveryStatus 'pending' is shown user-facing as "Confirmed".
|
||||||
expect(screen.getByTestId('order-status-tracker')).toBeVisible()
|
expect(screen.getByText('Confirmed')).toBeVisible()
|
||||||
expect(screen.getByText('Placed')).toBeVisible()
|
|
||||||
expect(screen.queryByText('Confirmed')).toBeNull()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('flags a flash order', async () => {
|
it('flags a flash order', async () => {
|
||||||
|
|
@ -102,8 +100,7 @@ describe('NextOrderGlimpse', () => {
|
||||||
await renderLoadedHome()
|
await renderLoadedHome()
|
||||||
|
|
||||||
await waitFor(() => expect(screen.getByText('FLASH')).toBeVisible())
|
await waitFor(() => expect(screen.getByText('FLASH')).toBeVisible())
|
||||||
expect(screen.getByText('30-Min')).toBeVisible()
|
expect(screen.getByText('30-Min Delivery')).toBeVisible()
|
||||||
expect(screen.getByText('Delivery')).toBeVisible()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('ignores cancelled and completed orders', async () => {
|
it('ignores cancelled and completed orders', async () => {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
* silent empty render.
|
* silent empty render.
|
||||||
*
|
*
|
||||||
* The tRPC URL is matched on the procedure path rather than the host, because
|
* The tRPC URL is matched on the procedure path rather than the host, because
|
||||||
* BASE_API_URL (@packages/shared) is a local address during development.
|
* BASE_API_URL (packages/ui/index.ts) is a local address during development.
|
||||||
* `jest.mock('axios')` lives in tests/setup.ts so it is registered before any
|
* `jest.mock('axios')` lives in tests/setup.ts so it is registered before any
|
||||||
* app module imports axios.
|
* app module imports axios.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,7 @@ import { routerMock } from '../mocks/router'
|
||||||
import { renderWithProviders } from '../helpers/render'
|
import { renderWithProviders } from '../helpers/render'
|
||||||
|
|
||||||
const PRODUCT_ID = 2 // Chicken Breast 500 g, price 215 (in stock, in a slot)
|
const PRODUCT_ID = 2 // Chicken Breast 500 g, price 215 (in stock, in a slot)
|
||||||
const OTHER_PRODUCT_ID = 40 // Chicken regular cut Large pieces (in stock)
|
|
||||||
const SLOT_ID = 1849
|
const SLOT_ID = 1849
|
||||||
const OTHER_SLOT_ID = 1850
|
|
||||||
|
|
||||||
const futureSlot = () => ({
|
const futureSlot = () => ({
|
||||||
id: SLOT_ID,
|
id: SLOT_ID,
|
||||||
|
|
@ -31,12 +29,6 @@ const futureSlot = () => ({
|
||||||
freezeTime: dayjs().add(2, 'hour').toISOString(),
|
freezeTime: dayjs().add(2, 'hour').toISOString(),
|
||||||
})
|
})
|
||||||
|
|
||||||
const otherFutureSlot = () => ({
|
|
||||||
id: OTHER_SLOT_ID,
|
|
||||||
deliveryTime: dayjs().add(5, 'hour').toISOString(),
|
|
||||||
freezeTime: dayjs().add(4, 'hour').toISOString(),
|
|
||||||
})
|
|
||||||
|
|
||||||
async function seedCart(items: unknown[]) {
|
async function seedCart(items: unknown[]) {
|
||||||
await StorageServiceCasual.setItem('cart_items', JSON.stringify(items))
|
await StorageServiceCasual.setItem('cart_items', JSON.stringify(items))
|
||||||
}
|
}
|
||||||
|
|
@ -125,70 +117,6 @@ describe('Cart screen', () => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows a pressable merge banner when every item can use the majority slot', async () => {
|
|
||||||
setupApiMocks({
|
|
||||||
procedures: {
|
|
||||||
'user.cart.getCartSlots': {
|
|
||||||
[PRODUCT_ID]: [futureSlot(), otherFutureSlot()],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
await seedCart([
|
|
||||||
cartItem({ id: 1, slotId: SLOT_ID }),
|
|
||||||
cartItem({ id: 2, slotId: OTHER_SLOT_ID }),
|
|
||||||
])
|
|
||||||
|
|
||||||
renderWithProviders(<CartPage />)
|
|
||||||
await waitFor(() =>
|
|
||||||
expect(screen.getAllByText('Chicken Breast 500 g').length).toBeGreaterThan(0)
|
|
||||||
)
|
|
||||||
|
|
||||||
await waitFor(() => expect(screen.getByTestId('delivery-slot-merge')).toBeVisible())
|
|
||||||
expect(screen.getByText(/Deliver All items at/)).toBeVisible()
|
|
||||||
expect(screen.getByTestId('delivery-slot-merge-apply')).toBeVisible()
|
|
||||||
|
|
||||||
fireEvent.press(screen.getByTestId('delivery-slot-merge-apply'))
|
|
||||||
|
|
||||||
// Merging onto one slot keeps the banner but removes the apply button.
|
|
||||||
await waitFor(() => expect(screen.queryByTestId('delivery-slot-merge-apply')).toBeNull())
|
|
||||||
expect(screen.getByTestId('delivery-slot-merge')).toBeVisible()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('shows the merge banner without the apply button when one item cannot use the majority slot', async () => {
|
|
||||||
setupApiMocks({
|
|
||||||
procedures: {
|
|
||||||
'user.cart.getCartSlots': {
|
|
||||||
[PRODUCT_ID]: [futureSlot(), otherFutureSlot()],
|
|
||||||
[OTHER_PRODUCT_ID]: [otherFutureSlot()],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
// Majority (lowest id) is SLOT_ID, which OTHER_PRODUCT_ID cannot use.
|
|
||||||
await seedCart([
|
|
||||||
cartItem({ id: 1, slotId: SLOT_ID }),
|
|
||||||
cartItem({ id: 2, skuId: OTHER_PRODUCT_ID, slotId: OTHER_SLOT_ID }),
|
|
||||||
])
|
|
||||||
|
|
||||||
renderWithProviders(<CartPage />)
|
|
||||||
await waitFor(() => expect(screen.getByTestId('delivery-slot-merge')).toBeVisible())
|
|
||||||
expect(screen.getByText(/Deliver All items at/)).toBeVisible()
|
|
||||||
expect(screen.queryByTestId('delivery-slot-merge-apply')).toBeNull()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('shows the merge banner without the apply button when only one slot is selected', async () => {
|
|
||||||
setupApiMocks({
|
|
||||||
procedures: { 'user.cart.getCartSlots': { [PRODUCT_ID]: [futureSlot()] } },
|
|
||||||
})
|
|
||||||
await seedCart([cartItem()])
|
|
||||||
|
|
||||||
renderWithProviders(<CartPage />)
|
|
||||||
await waitFor(() => expect(screen.getByText('Chicken Breast 500 g')).toBeVisible())
|
|
||||||
|
|
||||||
await waitFor(() => expect(screen.getByTestId('delivery-slot-merge')).toBeVisible())
|
|
||||||
expect(screen.getByText(/Deliver All items at/)).toBeVisible()
|
|
||||||
expect(screen.queryByTestId('delivery-slot-merge-apply')).toBeNull()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('renders the flash cart variant without slot selection', async () => {
|
it('renders the flash cart variant without slot selection', async () => {
|
||||||
setupApiMocks()
|
setupApiMocks()
|
||||||
await StorageServiceCasual.setItem(
|
await StorageServiceCasual.setItem(
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
import { createTRPCReact } from '@trpc/react-query'
|
import { createTRPCReact } from '@trpc/react-query'
|
||||||
import { createTRPCClient, httpBatchLink } from '@trpc/client'
|
import { createTRPCClient, httpBatchLink } from '@trpc/client'
|
||||||
import type { AppRouter } from '@backend/trpc/router'
|
import type { AppRouter } from '@backend/trpc/router'
|
||||||
import { BASE_API_URL as DEFAULT_API_URL } from '@packages/shared'
|
|
||||||
|
|
||||||
// const BASE_API_URL = 'http://192.168.100.111:8787'
|
// const BASE_API_URL = 'http://192.168.100.111:8787'
|
||||||
export const BASE_API_URL =
|
export const BASE_API_URL =
|
||||||
(import.meta.env?.VITE_API_URL as string | undefined) || DEFAULT_API_URL
|
(import.meta.env?.VITE_API_URL as string | undefined) || 'https://worker.freshyo.in'
|
||||||
|
|
||||||
export const trpc = createTRPCReact<AppRouter>()
|
export const trpc = createTRPCReact<AppRouter>()
|
||||||
|
|
||||||
|
|
|
||||||
135
change-log.txt
135
change-log.txt
|
|
@ -3586,138 +3586,3 @@ set to false so these render only in superadmin-ui:
|
||||||
apps/admin-ui/app/(drawer)/dashboard/customize-app/index.tsx — CONST_VISIBILITY:
|
apps/admin-ui/app/(drawer)/dashboard/customize-app/index.tsx — CONST_VISIBILITY:
|
||||||
internalAppVersion: true -> false
|
internalAppVersion: true -> false
|
||||||
(superadmin-ui's src/routes/constants.tsx keeps it visible, unchanged.)
|
(superadmin-ui's src/routes/constants.tsx keeps it visible, unchanged.)
|
||||||
|
|
||||||
[2026-10-02 00:16:36] refactor: move BASE_API_URL to @packages/shared so every UI uses one source.
|
|
||||||
|
|
||||||
packages/ui (common-ui) is React Native specific; the API base URL does not belong
|
|
||||||
there. It now lives in the framework-agnostic shared package, and packages/ui no
|
|
||||||
longer exports it.
|
|
||||||
|
|
||||||
- packages/shared/index.ts: export const BASE_API_URL = 'https://worker.freshyo.in'.
|
|
||||||
- packages/ui/index.ts: removed the local BASE_API_URL declaration + export.
|
|
||||||
- packages/ui/src/services/axios.ts: imports BASE_API_URL from '@packages/shared'.
|
|
||||||
- apps/user-ui/src/trpc-client.ts, apps/admin-ui/src/trpc-client.ts: import from
|
|
||||||
'@packages/shared' instead of 'common-ui'.
|
|
||||||
- apps/web-ui/src/lib/trpc-client.ts, apps/admin-web/..., apps/superadmin-ui/...:
|
|
||||||
default from '@packages/shared', still overridable via VITE_API_URL.
|
|
||||||
NOTE: admin-web's old devapi.freshyo.in default is gone; set
|
|
||||||
VITE_API_URL=https://devapi.freshyo.in for dev builds if still needed.
|
|
||||||
- apps/fallback-ui: vite alias for @packages/shared; baseUrl from the shared
|
|
||||||
constant.
|
|
||||||
- apps/user-ui/tests/mocks/api.ts: stale comment pointing at packages/ui.
|
|
||||||
|
|
||||||
[2026-10-02 00:24:19] admin-ui: fix typo in dashboard menu title ('Manage Orderss' -> 'Manage Orders').
|
|
||||||
|
|
||||||
Pre-existing regression surfaced while running the suite after the BASE_API_URL
|
|
||||||
move; the dashboard-hub tests expect 'Manage Orders'. Unrelated to the URL change.
|
|
||||||
|
|
||||||
[2026-10-02 00:28:44] user-ui: floating cart bar 'Go to Cart' button -> stacked 'Go to' / 'Cart'.
|
|
||||||
|
|
||||||
apps/user-ui/components/floating-cart-bar.tsx, collapsed-view button only:
|
|
||||||
-<MyText style={[tw`font-bold text-sm`, { color: cartBarColor }]}>Go to Cart</MyText>
|
|
||||||
+<View style={tw`items-center`}>
|
|
||||||
+ <MyText style={[tw`font-bold text-sm`, { color: cartBarColor }]}>Go to</MyText>
|
|
||||||
+ <MyText style={[tw`font-bold text-sm`, { color: cartBarColor }]}>Cart</MyText>
|
|
||||||
+</View>
|
|
||||||
|
|
||||||
[2026-10-02 00:31:53] user-ui: add WhatsApp contact button beside the floating cart bar.
|
|
||||||
|
|
||||||
apps/user-ui/components/floating-cart-bar.tsx
|
|
||||||
- wrap the collapsed bar in a flex-row; cart bar becomes flex-1 and a compact
|
|
||||||
green WhatsApp button sits to its right (ml-2), splitting the width.
|
|
||||||
- the button opens whatsapp://send?phone=<supportMobile from common.essentialConsts>,
|
|
||||||
normalising to a 10-digit number + '91' country code. Hidden when supportMobile
|
|
||||||
is empty or while the bar is expanded.
|
|
||||||
- imports: MaterialCommunityIcons (whatsapp glyph), expo-linking (openURL).
|
|
||||||
|
|
||||||
[2026-10-02 00:33:24] user-ui: floating cart bar WhatsApp button -> icon only (drop 'Chat' label).
|
|
||||||
|
|
||||||
[2026-10-02 00:36:40] user-ui: remove the WhatsApp support button from floating-cart-bar.
|
|
||||||
|
|
||||||
Reverts the split-row addition: cart bar back to full width; drops the
|
|
||||||
expo-linking / MaterialCommunityIcons imports, supportMobile handler and flex wrapper.
|
|
||||||
|
|
||||||
[2026-10-02 01:08:09] user-ui: NextOrderGlimpse - hide the status badge for Confirmed/Packaged.
|
|
||||||
|
|
||||||
OrderCard now computes statusLabel = orderStatusManipulator(deliveryStatus) and
|
|
||||||
omits the white status pill when the label is 'confirmed' or 'packaged'.
|
|
||||||
|
|
||||||
[2026-10-02 01:09:18] user-ui: NextOrderGlimpse - move delivery time into the top-right (status spot).
|
|
||||||
|
|
||||||
OrderCard: hoisted the delivery-time string into `deliveryTimeText`; the top row's
|
|
||||||
right column now shows the schedule/bolt + time (status pill, when visible, sits
|
|
||||||
under it). Removed the standalone delivery-time row below the header.
|
|
||||||
|
|
||||||
[2026-10-02 01:10:07] user-ui: NextOrderGlimpse - restyle the top-right delivery time as a 2-row pill.
|
|
||||||
|
|
||||||
Split deliveryTimeText into deliveryDateLabel (row 1: 'DD MMM' / '30-Min') and
|
|
||||||
deliveryTimeLabel (row 2: 'hh:mm A - hh:mm A' / 'Delivery'); wrapped in a white
|
|
||||||
rounded-2xl amber-border pill with the schedule/bolt icon.
|
|
||||||
|
|
||||||
[2026-10-02 01:12:05] user-ui: home - move NextOrderGlimpse above the tag tab strip.
|
|
||||||
|
|
||||||
app/(drawer)/(tabs)/home/index.tsx ListHeader: NextOrderGlimpse removed from the
|
|
||||||
white stores/slots section and rendered first, before <TagTabStrip>.
|
|
||||||
|
|
||||||
[2026-10-02 01:13:17] user-ui: NextOrderGlimpse - give the delivery TIME more emphasis than the date.
|
|
||||||
|
|
||||||
Swapped the pill labels so the primary line is the time range ('hh:mm A - hh:mm A',
|
|
||||||
or '30-Min' for flash) and the secondary line is the date ('DD MMM', or 'Delivery').
|
|
||||||
Primary: text-[13px] font-black text-amber-900; secondary: text-[9px] font-semibold text-amber-500.
|
|
||||||
|
|
||||||
[2026-10-02 01:14:27] user-ui: NextOrderGlimpse - don't repeat AM/PM when both times share the period.
|
|
||||||
|
|
||||||
Time range now renders '06:00 - 07:00 PM' when start/end period match, and
|
|
||||||
'11:00 AM - 12:00 PM' when they differ.
|
|
||||||
|
|
||||||
[2026-10-02 01:15:44] user-ui: NextOrderGlimpse - remove the 'Track Order' row; whole card already navigates.
|
|
||||||
|
|
||||||
Dropped the bordered item-thumbnails / 'Track Order' / chevron block. The card's
|
|
||||||
outer TouchableOpacity (onPress -> order detail) already covers the entire card.
|
|
||||||
Removed now-unused Ionicons and expo-image Image imports.
|
|
||||||
|
|
||||||
[2026-10-02 01:18:56] user-ui: add OrderStatusTracker (3 dots: Placed / Packed / Delivered).
|
|
||||||
|
|
||||||
New components/OrderStatusTracker.tsx:
|
|
||||||
- export deliveryStageIndex(deliveryStatus): pending/processing->0, packaged->1,
|
|
||||||
success/delivered->2, else 0.
|
|
||||||
- default export OrderStatusTracker { deliveryStatus, activeColor='#10B981', inactiveColor='#E2E8F0' };
|
|
||||||
renders 3 dots joined by lines with labels; reached stages filled (activeColor),
|
|
||||||
later stages muted; cancelled -> all muted.
|
|
||||||
Rendered in:
|
|
||||||
- components/NextOrderGlimpse.tsx (OrderCard, amber palette)
|
|
||||||
- app/(drawer)/(tabs)/me/my-orders/[id].tsx (new 'Order Status' card)
|
|
||||||
Tests: updated stale next-order-glimpse assertions (status pill hidden; flash label split).
|
|
||||||
|
|
||||||
[2026-10-02 01:21:25] user-ui: NextOrderGlimpse - add a top-right chevron indicating the card opens details.
|
|
||||||
|
|
||||||
Header row right side now holds the FLASH badge (when present) plus a
|
|
||||||
chevron-right (MaterialIcons, #B45309) as the tap affordance.
|
|
||||||
|
|
||||||
[2026-10-02 01:26:11] user-ui: cart-page - add a DeliverySlotSummary card before the checkout bar.
|
|
||||||
|
|
||||||
components/cart-page.tsx:
|
|
||||||
- new in-file component DeliverySlotSummary { groups }: 'Delivery Slot' card
|
|
||||||
listing each selected slot with its time label and a clickable 'n items';
|
|
||||||
tapping opens a BottomDialog listing that slot's items (image, name, unit, qty).
|
|
||||||
- formatDeliverySlot() helper; slotGroups useMemo groups cart lines by
|
|
||||||
selectedSlots[item.id] (non-flash only).
|
|
||||||
- rendered above the Bottom Checkout Bar (which holds Shop More / Checkout).
|
|
||||||
|
|
||||||
[2026-10-02 01:33:44] user-ui: cart-page - 'Deliver All items at <slot>' merge suggestion.
|
|
||||||
|
|
||||||
components/cart-page.tsx:
|
|
||||||
- DeliverySlotSummary gains mergeSuggestion + onMerge props; below the rows it
|
|
||||||
always shows 'Deliver All items at <label>' when >1 distinct slots are selected.
|
|
||||||
Feasible -> pressable row with chevron (merges all in-stock items onto that slot);
|
|
||||||
infeasible -> plain muted row, no button.
|
|
||||||
- mergeSuggestion useMemo picks the majority item-count selected slot
|
|
||||||
(tie-break lowest slot id) and flags feasible when every in-stock item can use it.
|
|
||||||
- handleMerge sets selectedSlots for all in-stock items.
|
|
||||||
Tests: added merge-banner cases in tests/screens/cart-screen.test.tsx (not run).
|
|
||||||
|
|
||||||
[2026-10-02 01:36:43] user-ui: cart-page - show merge banner even with a single slot (no button).
|
|
||||||
|
|
||||||
mergeSuggestion now returns whenever >=1 slot is selected (not only >1); `feasible`
|
|
||||||
(the apply button) additionally requires >1 distinct slots and a slot every item
|
|
||||||
can use. Single-slot -> muted banner, no button.
|
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,5 @@ export const CACHE_FILENAMES = {
|
||||||
banners: 'banners.json',
|
banners: 'banners.json',
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
/**
|
|
||||||
* Base origin of the backend API, shared by every UI (React Native and web).
|
|
||||||
* Framework-agnostic: apps may override it (e.g. VITE_API_URL) at build time.
|
|
||||||
*/
|
|
||||||
export const BASE_API_URL = 'https://worker.freshyo.in'
|
|
||||||
|
|
||||||
// Re-export all types from the types folder
|
// Re-export all types from the types folder
|
||||||
export * from './types'
|
export * from './types'
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,31 @@ import { InfoDialog } from "./src/components/info-dialog";
|
||||||
import { updateStatusBarColor, useStatusBarStore } from "./src/lib/status-bar-store";
|
import { updateStatusBarColor, useStatusBarStore } from "./src/lib/status-bar-store";
|
||||||
|
|
||||||
const isDevMode = Constants.executionEnvironment !== "standalone";
|
const isDevMode = Constants.executionEnvironment !== "standalone";
|
||||||
|
// const localhost =
|
||||||
|
// Platform.OS === "android"
|
||||||
|
// ? "http://10.0.2.2:4000" // Android emulator
|
||||||
|
// : "http://localhost:4000"; // iOS simulator / web dev
|
||||||
|
|
||||||
|
// const production = "https://technocracy.ovh/mf";
|
||||||
|
// // const production = "http://10.0.2.2:4000";
|
||||||
|
// // const production = "http://192.168.1.3:4000";
|
||||||
|
|
||||||
|
// const API_URL =
|
||||||
|
// Constants.executionEnvironment === "standalone" ? production : localhost;
|
||||||
|
|
||||||
|
// const BASE_API_URL = API_URL;
|
||||||
|
// const BASE_API_URL = 'http://10.0.2.2:4000';
|
||||||
|
// const BASE_API_URL = 'http://192.168.100.101:4000';
|
||||||
|
// const BASE_API_URL = 'http://192.168.1.5:8787';
|
||||||
|
// const BASE_API_URL = 'http://192.168.100.109:8787';
|
||||||
|
// let BASE_API_URL = "https://raw.freshyo.in";
|
||||||
|
let BASE_API_URL = "https://worker.freshyo.in";
|
||||||
|
// let BASE_API_URL = "https://devapi.freshyo.in";
|
||||||
|
// let BASE_API_URL = 'http://192.168.100.120:8787';
|
||||||
|
// let BASE_API_URL = 'http://192.168.29.176:4000';
|
||||||
|
|
||||||
|
// if(isDevMode) {
|
||||||
|
// }
|
||||||
|
|
||||||
export {
|
export {
|
||||||
StorageService,
|
StorageService,
|
||||||
|
|
@ -76,6 +101,7 @@ export {
|
||||||
useFocusCallback,
|
useFocusCallback,
|
||||||
useManualRefresh,
|
useManualRefresh,
|
||||||
useDrawerTitle,
|
useDrawerTitle,
|
||||||
|
BASE_API_URL,
|
||||||
useMarkDataFetchers,
|
useMarkDataFetchers,
|
||||||
StorageServiceCasual,
|
StorageServiceCasual,
|
||||||
REFUND_STATUS,
|
REFUND_STATUS,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import axiosParent from 'axios';
|
||||||
import { DeviceEventEmitter } from 'react-native'
|
import { DeviceEventEmitter } from 'react-native'
|
||||||
import { FORCE_LOGOUT_EVENT } from '../lib/const-strs';
|
import { FORCE_LOGOUT_EVENT } from '../lib/const-strs';
|
||||||
import { getAuthToken } from '@/hooks/useJWT';
|
import { getAuthToken } from '@/hooks/useJWT';
|
||||||
import { BASE_API_URL } from '@packages/shared';
|
import { BASE_API_URL } from '../../index';
|
||||||
|
|
||||||
// const API_BASE_URL = 'http://192.168.1.5:4000'; // Change to your API base URL
|
// const API_BASE_URL = 'http://192.168.1.5:4000'; // Change to your API base URL
|
||||||
// const API_BASE_URL = 'http://192.168.100.95:4000'; // Change to your API base URL
|
// const API_BASE_URL = 'http://192.168.100.95:4000'; // Change to your API base URL
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue