enh
This commit is contained in:
parent
0289c285c9
commit
a9c88e9ad7
8 changed files with 402 additions and 22 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { View, ScrollView } from 'react-native';
|
import { View, ScrollView, Linking } from 'react-native';
|
||||||
import { useRouter } from 'expo-router';
|
import { useRouter } from 'expo-router';
|
||||||
import { useFocusEffect } from '@react-navigation/native';
|
import { useFocusEffect } from '@react-navigation/native';
|
||||||
import { AppContainer, MyText, tw, MyTouchableOpacity, ProfileImage, colors } from 'common-ui';
|
import { AppContainer, MyText, tw, MyTouchableOpacity, ProfileImage, colors } from 'common-ui';
|
||||||
|
|
@ -11,6 +11,11 @@ import AddressSwitcherSheet from '@/src/components/location/AddressSwitcherSheet
|
||||||
import { useRegion } from '@/src/hooks/useRegion';
|
import { useRegion } from '@/src/hooks/useRegion';
|
||||||
import { useAuth } from '@/src/contexts/AuthContext';
|
import { useAuth } from '@/src/contexts/AuthContext';
|
||||||
import { useNavigationTarget } from 'common-ui/hooks/useNavigationTarget';
|
import { useNavigationTarget } from 'common-ui/hooks/useNavigationTarget';
|
||||||
|
import { useGetEssentialConsts } from '@/src/hooks/prominent-api-hooks';
|
||||||
|
import { isInNextOrderGlimpseWindow } from '@packages/shared';
|
||||||
|
import { trpc } from '@/src/trpc-client';
|
||||||
|
import { useUserDetails } from '@/src/contexts/AuthContext';
|
||||||
|
import type { Order } from '@/src/types/orders';
|
||||||
|
|
||||||
export default function Me() {
|
export default function Me() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
@ -18,6 +23,33 @@ export default function Me() {
|
||||||
const { getNavigationTarget } = useNavigationTarget();
|
const { getNavigationTarget } = useNavigationTarget();
|
||||||
const [regionDialogOpen, setRegionDialogOpen] = useState(false);
|
const [regionDialogOpen, setRegionDialogOpen] = useState(false);
|
||||||
const { region: selectedRegion } = useRegion();
|
const { region: selectedRegion } = useRegion();
|
||||||
|
// Same number the NextOrderGlimpse dials via tel: — Live Support opens it in WhatsApp.
|
||||||
|
const { data: essentialConsts } = useGetEssentialConsts();
|
||||||
|
const supportMobile = essentialConsts?.supportMobile ?? null;
|
||||||
|
const waDigits = (supportMobile ?? '').replace(/\D/g, '');
|
||||||
|
const waPhone = waDigits.length === 10 ? `91${waDigits}` : waDigits;
|
||||||
|
// Same upcoming orders the glimpse above shows; their ids prefill the message.
|
||||||
|
const userDetails = useUserDetails();
|
||||||
|
const { data: ordersData } = trpc.user.order.getOrders.useQuery(
|
||||||
|
{ page: 1, pageSize: 50 },
|
||||||
|
{ enabled: !!userDetails },
|
||||||
|
);
|
||||||
|
const upcomingIds = ((ordersData?.data as Order[] | undefined) ?? [])
|
||||||
|
.filter((order) => {
|
||||||
|
if (order.orderStatus.toLowerCase() === 'cancelled') return false;
|
||||||
|
if (order.deliveryStatus.toLowerCase() === 'success') return false;
|
||||||
|
return isInNextOrderGlimpseWindow(order);
|
||||||
|
})
|
||||||
|
.map((order) => order.orderId)
|
||||||
|
.filter(Boolean);
|
||||||
|
const waText = upcomingIds.length > 0 ? `Hi, my orders are ${upcomingIds.join(', ')}` : null;
|
||||||
|
const openWhatsApp = () => {
|
||||||
|
if (!waPhone) return;
|
||||||
|
const url = waText
|
||||||
|
? `whatsapp://send?phone=${waPhone}&text=${encodeURIComponent(waText)}`
|
||||||
|
: `whatsapp://send?phone=${waPhone}`;
|
||||||
|
Linking.openURL(url);
|
||||||
|
};
|
||||||
|
|
||||||
useFocusEffect(() => {
|
useFocusEffect(() => {
|
||||||
const target = getNavigationTarget();
|
const target = getNavigationTarget();
|
||||||
|
|
@ -52,6 +84,13 @@ export default function Me() {
|
||||||
onPress: () => router.push('/(drawer)/(tabs)/me/coupons'),
|
onPress: () => router.push('/(drawer)/(tabs)/me/coupons'),
|
||||||
subtitle: 'View active offers & rewards'
|
subtitle: 'View active offers & rewards'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Live Support',
|
||||||
|
icon: 'logo-whatsapp',
|
||||||
|
color: '#25D366',
|
||||||
|
onPress: openWhatsApp,
|
||||||
|
subtitle: supportMobile ? `Chat on WhatsApp • ${supportMobile}` : 'Chat with us on WhatsApp'
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
* `common-ui/hooks/useNavigationTarget` singleton.
|
* `common-ui/hooks/useNavigationTarget` singleton.
|
||||||
*/
|
*/
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Modal } from 'react-native'
|
import { Linking, Modal } from 'react-native'
|
||||||
import { act, fireEvent, render, waitFor } from '@testing-library/react-native'
|
import { act, fireEvent, render, waitFor } from '@testing-library/react-native'
|
||||||
import { useNavigationTarget } from 'common-ui/hooks/useNavigationTarget'
|
import { useNavigationTarget } from 'common-ui/hooks/useNavigationTarget'
|
||||||
|
|
||||||
|
|
@ -18,9 +18,10 @@ import Me from '@/app/(drawer)/(tabs)/me/index'
|
||||||
|
|
||||||
import { flush, renderWithProviders, seedRegion } from '../helpers/test-utils'
|
import { flush, renderWithProviders, seedRegion } from '../helpers/test-utils'
|
||||||
import { resetAllMocks } from '../helpers/reset'
|
import { resetAllMocks } from '../helpers/reset'
|
||||||
|
import { setProcedure } from '../mocks/trpc-client'
|
||||||
import { router } from '../mocks/expo-router-mock'
|
import { router } from '../mocks/expo-router-mock'
|
||||||
import { __snapshot } from '../mocks/secure-store-mock'
|
import { __snapshot } from '../mocks/secure-store-mock'
|
||||||
import { REGION_1 } from '../fixtures'
|
import { CONSTS, REGION_1 } from '../fixtures'
|
||||||
|
|
||||||
async function renderHub() {
|
async function renderHub() {
|
||||||
const view = renderWithProviders(<Me />, { auth: 'in' })
|
const view = renderWithProviders(<Me />, { auth: 'in' })
|
||||||
|
|
@ -69,6 +70,7 @@ describe('Me hub (ME-01..ME-19)', () => {
|
||||||
'me-menu-addresses',
|
'me-menu-addresses',
|
||||||
'me-menu-delivery-address',
|
'me-menu-delivery-address',
|
||||||
'me-menu-profile-settings',
|
'me-menu-profile-settings',
|
||||||
|
'me-menu-live-support',
|
||||||
'me-menu-help-complaints',
|
'me-menu-help-complaints',
|
||||||
'me-menu-terms-conditions',
|
'me-menu-terms-conditions',
|
||||||
]
|
]
|
||||||
|
|
@ -239,4 +241,50 @@ describe('Me hub (ME-01..ME-19)', () => {
|
||||||
expect(view.getByTestId('me-version')).toBeTruthy()
|
expect(view.getByTestId('me-version')).toBeTruthy()
|
||||||
expect(view.getByText('Version 1.2.0 • Freshyo App')).toBeTruthy()
|
expect(view.getByText('Version 1.2.0 • Freshyo App')).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('ME-20: Live Support opens WhatsApp to the essential-consts support mobile', async () => {
|
||||||
|
seedRegion(REGION_1, 7)
|
||||||
|
const openURL = jest.spyOn(Linking, 'openURL').mockResolvedValue(true as any)
|
||||||
|
const view = await renderHub()
|
||||||
|
|
||||||
|
expect(await view.findByText('Chat on WhatsApp • 8688182552')).toBeTruthy()
|
||||||
|
fireEvent.press(view.getByTestId('me-menu-live-support'))
|
||||||
|
|
||||||
|
// Default fixtures leave O1/O2/O5/O6 upcoming (O3 cancelled, O4 delivered).
|
||||||
|
expect(openURL).toHaveBeenCalledWith(
|
||||||
|
'whatsapp://send?phone=918688182552&text=Hi%2C%20my%20orders%20are%20ORD-1001%2C%20ORD-1002%2C%20ORD-1005%2C%20ORD-1006'
|
||||||
|
)
|
||||||
|
|
||||||
|
// Placed directly below the Coupons entry.
|
||||||
|
const tree = JSON.stringify(view.toJSON())
|
||||||
|
expect(tree.indexOf('me-menu-live-support')).toBeGreaterThan(tree.indexOf('me-menu-coupons'))
|
||||||
|
})
|
||||||
|
|
||||||
|
it('ME-21: Live Support is a no-op when the support mobile is missing', async () => {
|
||||||
|
seedRegion(REGION_1, 7)
|
||||||
|
setProcedure('common.essentialConsts', {
|
||||||
|
data: { ...CONSTS, supportMobile: null },
|
||||||
|
})
|
||||||
|
const openURL = jest.spyOn(Linking, 'openURL').mockResolvedValue(true as any)
|
||||||
|
const view = await renderHub()
|
||||||
|
|
||||||
|
expect(view.getByText('Chat with us on WhatsApp')).toBeTruthy()
|
||||||
|
fireEvent.press(view.getByTestId('me-menu-live-support'))
|
||||||
|
|
||||||
|
expect(openURL).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('ME-22: with no upcoming orders Live Support opens WhatsApp without a message', async () => {
|
||||||
|
seedRegion(REGION_1, 7)
|
||||||
|
setProcedure('user.order.getOrders', {
|
||||||
|
data: { data: [], pagination: { totalPages: 1, total: 0, page: 1, pageSize: 50 } },
|
||||||
|
})
|
||||||
|
const openURL = jest.spyOn(Linking, 'openURL').mockResolvedValue(true as any)
|
||||||
|
const view = await renderHub()
|
||||||
|
|
||||||
|
expect(await view.findByText('Chat on WhatsApp • 8688182552')).toBeTruthy()
|
||||||
|
fireEvent.press(view.getByTestId('me-menu-live-support'))
|
||||||
|
|
||||||
|
expect(openURL).toHaveBeenCalledWith('whatsapp://send?phone=918688182552')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
108
apps/web-ui/src/components/QrDownloadPage.tsx
Normal file
108
apps/web-ui/src/components/QrDownloadPage.tsx
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
import React, { useEffect } from 'react'
|
||||||
|
import { Link } from '@tanstack/react-router'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Port of apps/info-site/views/qr-download.pug: the QR-based download page.
|
||||||
|
* Same store URLs, same user-agent auto-redirect, same three option cards
|
||||||
|
* with the same glyphs and click handlers that assign window.location.href.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const ANDROID_URL =
|
||||||
|
'intent://play.google.com/store/apps/details?id=in.freshyo.app#Intent;scheme=https;package=com.android.vending;end;'
|
||||||
|
export const IOS_URL = 'https://apps.apple.com/in/app/freshyo/id6756889077'
|
||||||
|
export const BROWSER_URL = 'https://app.freshyo.in'
|
||||||
|
|
||||||
|
function detectOS(): 'android' | 'ios' | 'unknown' {
|
||||||
|
if (typeof navigator === 'undefined') return 'unknown'
|
||||||
|
const userAgent = navigator.userAgent || (navigator as any).vendor || (window as any).opera
|
||||||
|
if (/android/i.test(userAgent)) return 'android'
|
||||||
|
if (/iPad|iPhone|iPod/.test(userAgent) && !(window as any).MSStream) return 'ios'
|
||||||
|
return 'unknown'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function QrDownloadPage() {
|
||||||
|
// Same as the info-site's window-load redirect: android/ios go straight to
|
||||||
|
// their store; anything else stays so the user can pick.
|
||||||
|
useEffect(() => {
|
||||||
|
const os = detectOS()
|
||||||
|
if (os === 'android') window.location.href = ANDROID_URL
|
||||||
|
else if (os === 'ios') window.location.href = IOS_URL
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const go = (url: string) => (e: React.MouseEvent) => {
|
||||||
|
e.preventDefault()
|
||||||
|
window.location.href = url
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex min-h-screen items-center justify-center bg-gray-50 p-6">
|
||||||
|
<div className="w-full max-w-[400px] rounded-2xl border border-gray-100 bg-white p-8 text-center shadow-xl">
|
||||||
|
<Link
|
||||||
|
to="/home"
|
||||||
|
className="mb-4 block text-left text-sm font-medium text-gray-500 transition-colors hover:text-gray-900"
|
||||||
|
>
|
||||||
|
← Back to Home
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<img src="/freshyo-logo.png" alt="Freshyo" width={80} height={80} className="mx-auto mb-4 rounded-xl" />
|
||||||
|
<h1 className="mb-1 text-2xl font-bold text-gray-900">Download Freshyo</h1>
|
||||||
|
<p className="mb-4 text-sm font-semibold text-brand-600">Freshness Delivered, Smiles Picked Up</p>
|
||||||
|
<p className="text-gray-600">Choose your platform to get started</p>
|
||||||
|
|
||||||
|
<div className="mt-6 flex flex-col gap-4">
|
||||||
|
<a
|
||||||
|
href={ANDROID_URL}
|
||||||
|
onClick={go(ANDROID_URL)}
|
||||||
|
className="group flex items-center gap-4 rounded-xl border-2 border-gray-200 bg-white p-4 text-left text-gray-900 no-underline transition-all hover:translate-x-1 hover:border-[#3DDC84] hover:shadow-md"
|
||||||
|
>
|
||||||
|
<span className="flex h-12 w-12 shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-[#3DDC84] to-[#2AA852] text-white">
|
||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
|
||||||
|
<path d="M17.6 9.48l1.84-3.18c.16-.31.04-.69-.26-.85-.29-.15-.65-.06-.83.22l-1.88 3.24a11.463 11.463 0 0 0-8.94 0L5.65 5.67c-.19-.29-.58-.38-.87-.2-.28.18-.37.54-.22.83L6.4 9.48A10.78 10.78 0 0 0 1 18h22a10.78 10.78 0 0 0-5.4-8.52zM7 15.25a1.25 1.25 0 1 1 0-2.5 1.25 1.25 0 0 1 0 2.5zm10 0a1.25 1.25 0 1 1 0-2.5 1.25 1.25 0 0 1 0 2.5z" />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<span className="flex-1">
|
||||||
|
<span className="block text-base font-semibold">Android</span>
|
||||||
|
<span className="block text-sm text-gray-500">Google Play Store</span>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a
|
||||||
|
href={IOS_URL}
|
||||||
|
onClick={go(IOS_URL)}
|
||||||
|
className="group flex items-center gap-4 rounded-xl border-2 border-gray-200 bg-white p-4 text-left text-gray-900 no-underline transition-all hover:translate-x-1 hover:border-brand-500 hover:shadow-md"
|
||||||
|
>
|
||||||
|
<span className="flex h-12 w-12 shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-brand-500 to-brand-700 text-white">
|
||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
|
||||||
|
<path d="M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.21-1.96 1.07-3.11-1.05.05-2.31.7-3.06 1.58-.68.77-1.28 2-1.12 3.16 1.19.09 2.41-.79 3.11-1.63z" />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<span className="flex-1">
|
||||||
|
<span className="block text-base font-semibold">iOS</span>
|
||||||
|
<span className="block text-sm text-gray-500">Apple App Store</span>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a
|
||||||
|
href={BROWSER_URL}
|
||||||
|
onClick={go(BROWSER_URL)}
|
||||||
|
className="group flex items-center gap-4 rounded-xl border-2 border-dashed border-gray-200 bg-brand-50 p-4 text-left text-gray-900 no-underline transition-all hover:translate-x-1 hover:border-solid hover:border-brand-400 hover:bg-white hover:shadow-md"
|
||||||
|
>
|
||||||
|
<span className="flex h-12 w-12 shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-gray-400 to-gray-500 text-white">
|
||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||||
|
<circle cx="12" cy="12" r="10" />
|
||||||
|
<path d="M2 12h20" />
|
||||||
|
<path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<span className="flex-1">
|
||||||
|
<span className="block text-base font-semibold">Use in Browser</span>
|
||||||
|
<span className="block text-sm text-gray-500">No download required</span>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p className="mt-6 text-sm text-gray-500">Not redirected? Tap an option above</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -12,6 +12,8 @@ import { Route as rootRouteImport } from './routes/__root'
|
||||||
import { Route as StoresRouteImport } from './routes/stores'
|
import { Route as StoresRouteImport } from './routes/stores'
|
||||||
import { Route as SlotViewRouteImport } from './routes/slot-view'
|
import { Route as SlotViewRouteImport } from './routes/slot-view'
|
||||||
import { Route as RegisterRouteImport } from './routes/register'
|
import { Route as RegisterRouteImport } from './routes/register'
|
||||||
|
import { Route as QrDownloadRouteImport } from './routes/qr-download'
|
||||||
|
import { Route as QrBasedDownloadRouteImport } from './routes/qr-based-download'
|
||||||
import { Route as OffersRouteImport } from './routes/offers'
|
import { Route as OffersRouteImport } from './routes/offers'
|
||||||
import { Route as MeRouteImport } from './routes/me'
|
import { Route as MeRouteImport } from './routes/me'
|
||||||
import { Route as LoginRouteImport } from './routes/login'
|
import { Route as LoginRouteImport } from './routes/login'
|
||||||
|
|
@ -57,6 +59,16 @@ const RegisterRoute = RegisterRouteImport.update({
|
||||||
path: '/register',
|
path: '/register',
|
||||||
getParentRoute: () => rootRouteImport,
|
getParentRoute: () => rootRouteImport,
|
||||||
} as any)
|
} as any)
|
||||||
|
const QrDownloadRoute = QrDownloadRouteImport.update({
|
||||||
|
id: '/qr-download',
|
||||||
|
path: '/qr-download',
|
||||||
|
getParentRoute: () => rootRouteImport,
|
||||||
|
} as any)
|
||||||
|
const QrBasedDownloadRoute = QrBasedDownloadRouteImport.update({
|
||||||
|
id: '/qr-based-download',
|
||||||
|
path: '/qr-based-download',
|
||||||
|
getParentRoute: () => rootRouteImport,
|
||||||
|
} as any)
|
||||||
const OffersRoute = OffersRouteImport.update({
|
const OffersRoute = OffersRouteImport.update({
|
||||||
id: '/offers',
|
id: '/offers',
|
||||||
path: '/offers',
|
path: '/offers',
|
||||||
|
|
@ -214,6 +226,8 @@ export interface FileRoutesByFullPath {
|
||||||
'/login': typeof LoginRoute
|
'/login': typeof LoginRoute
|
||||||
'/me': typeof MeRouteWithChildren
|
'/me': typeof MeRouteWithChildren
|
||||||
'/offers': typeof OffersRoute
|
'/offers': typeof OffersRoute
|
||||||
|
'/qr-based-download': typeof QrBasedDownloadRoute
|
||||||
|
'/qr-download': typeof QrDownloadRoute
|
||||||
'/register': typeof RegisterRoute
|
'/register': typeof RegisterRoute
|
||||||
'/slot-view': typeof SlotViewRoute
|
'/slot-view': typeof SlotViewRoute
|
||||||
'/stores': typeof StoresRouteWithChildren
|
'/stores': typeof StoresRouteWithChildren
|
||||||
|
|
@ -247,6 +261,8 @@ export interface FileRoutesByTo {
|
||||||
'/login': typeof LoginRoute
|
'/login': typeof LoginRoute
|
||||||
'/me': typeof MeRouteWithChildren
|
'/me': typeof MeRouteWithChildren
|
||||||
'/offers': typeof OffersRoute
|
'/offers': typeof OffersRoute
|
||||||
|
'/qr-based-download': typeof QrBasedDownloadRoute
|
||||||
|
'/qr-download': typeof QrDownloadRoute
|
||||||
'/register': typeof RegisterRoute
|
'/register': typeof RegisterRoute
|
||||||
'/slot-view': typeof SlotViewRoute
|
'/slot-view': typeof SlotViewRoute
|
||||||
'/stores': typeof StoresRouteWithChildren
|
'/stores': typeof StoresRouteWithChildren
|
||||||
|
|
@ -282,6 +298,8 @@ export interface FileRoutesById {
|
||||||
'/login': typeof LoginRoute
|
'/login': typeof LoginRoute
|
||||||
'/me': typeof MeRouteWithChildren
|
'/me': typeof MeRouteWithChildren
|
||||||
'/offers': typeof OffersRoute
|
'/offers': typeof OffersRoute
|
||||||
|
'/qr-based-download': typeof QrBasedDownloadRoute
|
||||||
|
'/qr-download': typeof QrDownloadRoute
|
||||||
'/register': typeof RegisterRoute
|
'/register': typeof RegisterRoute
|
||||||
'/slot-view': typeof SlotViewRoute
|
'/slot-view': typeof SlotViewRoute
|
||||||
'/stores': typeof StoresRouteWithChildren
|
'/stores': typeof StoresRouteWithChildren
|
||||||
|
|
@ -318,6 +336,8 @@ export interface FileRouteTypes {
|
||||||
| '/login'
|
| '/login'
|
||||||
| '/me'
|
| '/me'
|
||||||
| '/offers'
|
| '/offers'
|
||||||
|
| '/qr-based-download'
|
||||||
|
| '/qr-download'
|
||||||
| '/register'
|
| '/register'
|
||||||
| '/slot-view'
|
| '/slot-view'
|
||||||
| '/stores'
|
| '/stores'
|
||||||
|
|
@ -351,6 +371,8 @@ export interface FileRouteTypes {
|
||||||
| '/login'
|
| '/login'
|
||||||
| '/me'
|
| '/me'
|
||||||
| '/offers'
|
| '/offers'
|
||||||
|
| '/qr-based-download'
|
||||||
|
| '/qr-download'
|
||||||
| '/register'
|
| '/register'
|
||||||
| '/slot-view'
|
| '/slot-view'
|
||||||
| '/stores'
|
| '/stores'
|
||||||
|
|
@ -385,6 +407,8 @@ export interface FileRouteTypes {
|
||||||
| '/login'
|
| '/login'
|
||||||
| '/me'
|
| '/me'
|
||||||
| '/offers'
|
| '/offers'
|
||||||
|
| '/qr-based-download'
|
||||||
|
| '/qr-download'
|
||||||
| '/register'
|
| '/register'
|
||||||
| '/slot-view'
|
| '/slot-view'
|
||||||
| '/stores'
|
| '/stores'
|
||||||
|
|
@ -420,6 +444,8 @@ export interface RootRouteChildren {
|
||||||
LoginRoute: typeof LoginRoute
|
LoginRoute: typeof LoginRoute
|
||||||
MeRoute: typeof MeRouteWithChildren
|
MeRoute: typeof MeRouteWithChildren
|
||||||
OffersRoute: typeof OffersRoute
|
OffersRoute: typeof OffersRoute
|
||||||
|
QrBasedDownloadRoute: typeof QrBasedDownloadRoute
|
||||||
|
QrDownloadRoute: typeof QrDownloadRoute
|
||||||
RegisterRoute: typeof RegisterRoute
|
RegisterRoute: typeof RegisterRoute
|
||||||
SlotViewRoute: typeof SlotViewRoute
|
SlotViewRoute: typeof SlotViewRoute
|
||||||
StoresRoute: typeof StoresRouteWithChildren
|
StoresRoute: typeof StoresRouteWithChildren
|
||||||
|
|
@ -448,6 +474,20 @@ declare module '@tanstack/react-router' {
|
||||||
preLoaderRoute: typeof RegisterRouteImport
|
preLoaderRoute: typeof RegisterRouteImport
|
||||||
parentRoute: typeof rootRouteImport
|
parentRoute: typeof rootRouteImport
|
||||||
}
|
}
|
||||||
|
'/qr-download': {
|
||||||
|
id: '/qr-download'
|
||||||
|
path: '/qr-download'
|
||||||
|
fullPath: '/qr-download'
|
||||||
|
preLoaderRoute: typeof QrDownloadRouteImport
|
||||||
|
parentRoute: typeof rootRouteImport
|
||||||
|
}
|
||||||
|
'/qr-based-download': {
|
||||||
|
id: '/qr-based-download'
|
||||||
|
path: '/qr-based-download'
|
||||||
|
fullPath: '/qr-based-download'
|
||||||
|
preLoaderRoute: typeof QrBasedDownloadRouteImport
|
||||||
|
parentRoute: typeof rootRouteImport
|
||||||
|
}
|
||||||
'/offers': {
|
'/offers': {
|
||||||
id: '/offers'
|
id: '/offers'
|
||||||
path: '/offers'
|
path: '/offers'
|
||||||
|
|
@ -757,6 +797,8 @@ const rootRouteChildren: RootRouteChildren = {
|
||||||
LoginRoute: LoginRoute,
|
LoginRoute: LoginRoute,
|
||||||
MeRoute: MeRouteWithChildren,
|
MeRoute: MeRouteWithChildren,
|
||||||
OffersRoute: OffersRoute,
|
OffersRoute: OffersRoute,
|
||||||
|
QrBasedDownloadRoute: QrBasedDownloadRoute,
|
||||||
|
QrDownloadRoute: QrDownloadRoute,
|
||||||
RegisterRoute: RegisterRoute,
|
RegisterRoute: RegisterRoute,
|
||||||
SlotViewRoute: SlotViewRoute,
|
SlotViewRoute: SlotViewRoute,
|
||||||
StoresRoute: StoresRouteWithChildren,
|
StoresRoute: StoresRouteWithChildren,
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,16 @@ import {
|
||||||
Globe,
|
Globe,
|
||||||
User,
|
User,
|
||||||
MessageSquare,
|
MessageSquare,
|
||||||
|
MessageCircle,
|
||||||
FileText,
|
FileText,
|
||||||
LogOut,
|
LogOut,
|
||||||
ChevronRight,
|
ChevronRight,
|
||||||
Settings,
|
Settings,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
|
import { useGetEssentialConsts } from '../hooks/prominent-api-hooks'
|
||||||
|
import { isInNextOrderGlimpseWindow } from '@packages/shared'
|
||||||
|
import { trpc } from '../lib/trpc-client'
|
||||||
|
|
||||||
export const Route = createFileRoute('/me')({ component: MePage })
|
export const Route = createFileRoute('/me')({ component: MePage })
|
||||||
|
|
||||||
|
|
@ -27,7 +31,8 @@ interface MenuItem {
|
||||||
title: string
|
title: string
|
||||||
icon: React.ComponentType<{ size?: number | string; color?: string }>
|
icon: React.ComponentType<{ size?: number | string; color?: string }>
|
||||||
color: string
|
color: string
|
||||||
to: string
|
to?: string
|
||||||
|
href?: string
|
||||||
subtitle: string
|
subtitle: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,6 +59,30 @@ function MePage() {
|
||||||
const [regionDialogOpen, setRegionDialogOpen] = useState(false)
|
const [regionDialogOpen, setRegionDialogOpen] = useState(false)
|
||||||
const selectedRegion = useRegionStore((state) => state.selectedRegion)
|
const selectedRegion = useRegionStore((state) => state.selectedRegion)
|
||||||
const selectedRegionId = useRegionStore((state) => state.selectedRegionId)
|
const selectedRegionId = useRegionStore((state) => state.selectedRegionId)
|
||||||
|
// Same number the NextOrderGlimpse dials via tel: — Live Support opens it in WhatsApp.
|
||||||
|
const { data: essentialConsts } = useGetEssentialConsts()
|
||||||
|
const supportMobile = (essentialConsts as any)?.supportMobile ?? null
|
||||||
|
const waDigits = String(supportMobile ?? '').replace(/\D/g, '')
|
||||||
|
const waPhone = waDigits.length === 10 ? `91${waDigits}` : waDigits
|
||||||
|
// Same upcoming orders the glimpse above shows; their ids prefill the message.
|
||||||
|
const { data: ordersData } = trpc.user.order.getOrders.useQuery(
|
||||||
|
{ page: 1, pageSize: 50 },
|
||||||
|
{ enabled: !!user }
|
||||||
|
)
|
||||||
|
const upcomingIds: string[] = ((ordersData as any)?.data ?? [])
|
||||||
|
.filter((order: any) => {
|
||||||
|
if (String(order.orderStatus).toLowerCase() === 'cancelled') return false
|
||||||
|
if (String(order.deliveryStatus).toLowerCase() === 'success') return false
|
||||||
|
return isInNextOrderGlimpseWindow(order)
|
||||||
|
})
|
||||||
|
.map((order: any) => order.orderId)
|
||||||
|
.filter(Boolean)
|
||||||
|
const waText = upcomingIds.length > 0 ? `Hi, my orders are ${upcomingIds.join(', ')}` : null
|
||||||
|
const waHref = waPhone
|
||||||
|
? waText
|
||||||
|
? `https://wa.me/${waPhone}?text=${encodeURIComponent(waText)}`
|
||||||
|
: `https://wa.me/${waPhone}`
|
||||||
|
: undefined
|
||||||
|
|
||||||
// Check if we're on the exact /me path (not a child route like /me/orders)
|
// Check if we're on the exact /me path (not a child route like /me/orders)
|
||||||
const isExactMePath = location.pathname === '/me'
|
const isExactMePath = location.pathname === '/me'
|
||||||
|
|
@ -98,6 +127,19 @@ function MePage() {
|
||||||
to: '/me/coupons',
|
to: '/me/coupons',
|
||||||
subtitle: 'View active offers & rewards',
|
subtitle: 'View active offers & rewards',
|
||||||
},
|
},
|
||||||
|
...(waHref
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
title: 'Live Support',
|
||||||
|
icon: MessageCircle,
|
||||||
|
color: '#25D366',
|
||||||
|
href: waHref,
|
||||||
|
subtitle: supportMobile
|
||||||
|
? `Chat on WhatsApp • ${supportMobile}`
|
||||||
|
: 'Chat with us on WhatsApp',
|
||||||
|
} as MenuItem,
|
||||||
|
]
|
||||||
|
: []),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -168,24 +210,42 @@ function MePage() {
|
||||||
{section.title}
|
{section.title}
|
||||||
</p>
|
</p>
|
||||||
<div className="overflow-hidden rounded-[32px] border border-gray-100 bg-white shadow-sm">
|
<div className="overflow-hidden rounded-[32px] border border-gray-100 bg-white shadow-sm">
|
||||||
{section.items.map((item, iIndex) => (
|
{section.items.map((item, iIndex) => {
|
||||||
<button
|
const rowClass = `flex w-full flex-row items-center p-4 text-left transition-colors hover:bg-gray-50 ${
|
||||||
key={iIndex}
|
iIndex !== section.items.length - 1 ? 'border-b border-gray-50' : ''
|
||||||
onClick={() => navigate({ to: item.to as any })}
|
}`
|
||||||
className={`flex w-full flex-row items-center p-4 text-left transition-colors hover:bg-gray-50 ${
|
const rowContent = (
|
||||||
iIndex !== section.items.length - 1 ? 'border-b border-gray-50' : ''
|
<>
|
||||||
}`}
|
<MenuIcon icon={item.icon} color={item.color} />
|
||||||
>
|
<div className="min-w-0 flex-1">
|
||||||
<MenuIcon icon={item.icon} color={item.color} />
|
<p className="text-base font-semibold text-gray-800">{item.title}</p>
|
||||||
<div className="min-w-0 flex-1">
|
<p className="mt-0.5 text-xs text-gray-400">{item.subtitle}</p>
|
||||||
<p className="text-base font-semibold text-gray-800">{item.title}</p>
|
</div>
|
||||||
<p className="mt-0.5 text-xs text-gray-400">{item.subtitle}</p>
|
<div className="ml-2 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gray-50">
|
||||||
</div>
|
<ChevronRight size={16} color="#94A3B8" />
|
||||||
<div className="ml-2 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gray-50">
|
</div>
|
||||||
<ChevronRight size={16} color="#94A3B8" />
|
</>
|
||||||
</div>
|
)
|
||||||
</button>
|
return item.href ? (
|
||||||
))}
|
<a
|
||||||
|
key={iIndex}
|
||||||
|
href={item.href}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
className={rowClass}
|
||||||
|
>
|
||||||
|
{rowContent}
|
||||||
|
</a>
|
||||||
|
) : (
|
||||||
|
<button
|
||||||
|
key={iIndex}
|
||||||
|
onClick={() => navigate({ to: item.to as any })}
|
||||||
|
className={rowClass}
|
||||||
|
>
|
||||||
|
{rowContent}
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
|
||||||
9
apps/web-ui/src/routes/qr-based-download.tsx
Normal file
9
apps/web-ui/src/routes/qr-based-download.tsx
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { createFileRoute } from '@tanstack/react-router'
|
||||||
|
import { QrDownloadPage } from '../components/QrDownloadPage'
|
||||||
|
|
||||||
|
export const Route = createFileRoute('/qr-based-download')({
|
||||||
|
head: () => ({
|
||||||
|
meta: [{ title: 'Freshyo - Download App' }],
|
||||||
|
}),
|
||||||
|
component: QrDownloadPage,
|
||||||
|
})
|
||||||
9
apps/web-ui/src/routes/qr-download.tsx
Normal file
9
apps/web-ui/src/routes/qr-download.tsx
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { createFileRoute } from '@tanstack/react-router'
|
||||||
|
import { QrDownloadPage } from '../components/QrDownloadPage'
|
||||||
|
|
||||||
|
export const Route = createFileRoute('/qr-download')({
|
||||||
|
head: () => ({
|
||||||
|
meta: [{ title: 'Freshyo - Download App' }],
|
||||||
|
}),
|
||||||
|
component: QrDownloadPage,
|
||||||
|
})
|
||||||
|
|
@ -9431,3 +9431,68 @@ No migration needed; the rows and defaults are unchanged.
|
||||||
+ it('SREG-11b (regression): a region with 17 bounds creates and seeds every bound', ...)
|
+ it('SREG-11b (regression): a region with 17 bounds creates and seeds every bound', ...)
|
||||||
+ // 6 bounds overflowed the old 120-param settings insert; 17 also splits the
|
+ // 6 bounds overflowed the old 120-param settings insert; 17 also splits the
|
||||||
+ // region_bounds insert. Asserts 17 bounds and 5 settings on each.
|
+ // region_bounds insert. Asserts 17 bounds and 5 settings on each.
|
||||||
|
|
||||||
|
[2026-10-24 19:05 IST] user-ui + web-ui: Me hub "Live Support" WhatsApp entry (same supportMobile as NextOrderGlimpse).
|
||||||
|
Same number the glimpse dials via tel: now also opens WhatsApp: RN Linking.openURL
|
||||||
|
whatsapp://send?phone=<digits with 91 prefix>; web opens https://wa.me/<same digits>.
|
||||||
|
Ionicons logo-whatsapp (#25D366) on native, MessageCircle (#25D366) on web (no brand
|
||||||
|
glyph in lucide). Guarded no-op when supportMobile is missing.
|
||||||
|
|
||||||
|
--- a/apps/user-ui/app/(drawer)/(tabs)/me/index.tsx
|
||||||
|
+++ b/apps/user-ui/app/(drawer)/(tabs)/me/index.tsx
|
||||||
|
@@ imports
|
||||||
|
+import { Linking } from 'react-native'
|
||||||
|
+import { useGetEssentialConsts } from '@/src/hooks/prominent-api-hooks'
|
||||||
|
@@ component
|
||||||
|
+ const { data: essentialConsts } = useGetEssentialConsts()
|
||||||
|
+ const supportMobile = essentialConsts?.supportMobile ?? null
|
||||||
|
+ const digits = (supportMobile ?? '').replace(/\D/g, '')
|
||||||
|
+ const waPhone = digits.length === 10 ? `91${digits}` : digits
|
||||||
|
+ const openWhatsApp = () => { if (waPhone) Linking.openURL(`whatsapp://send?phone=${waPhone}`) }
|
||||||
|
@@ Support section items
|
||||||
|
+ { title: 'Live Support', icon: 'logo-whatsapp', color: '#25D366',
|
||||||
|
+ onPress: openWhatsApp,
|
||||||
|
+ subtitle: supportMobile ? `Chat on WhatsApp • ${supportMobile}` : 'Chat with us on WhatsApp' },
|
||||||
|
|
||||||
|
--- a/apps/web-ui/src/routes/me.tsx
|
||||||
|
+++ b/apps/web-ui/src/routes/me.tsx
|
||||||
|
@@ imports
|
||||||
|
+import { MessageCircle } from 'lucide-react'
|
||||||
|
+import { useGetEssentialConsts } from '../hooks/prominent-api-hooks'
|
||||||
|
@@ MenuItem type
|
||||||
|
- to: string
|
||||||
|
+ to?: string; href?: string
|
||||||
|
@@ render
|
||||||
|
+ {item.href ? <a href={item.href} target="_blank" rel="noreferrer">…</a> : <button navigate(item.to)>…</button>}
|
||||||
|
@@ Support section items
|
||||||
|
+ { title: 'Live Support', icon: MessageCircle, color: '#25D366',
|
||||||
|
+ href: https://wa.me/<same waPhone>, subtitle: same as native },
|
||||||
|
|
||||||
|
--- a/apps/user-ui/tests/pages/me-hub.test.tsx
|
||||||
|
+++ b/apps/user-ui/tests/pages/me-hub.test.tsx
|
||||||
|
@@ ME-01 entries
|
||||||
|
+ 'me-menu-live-support',
|
||||||
|
@@ new rows
|
||||||
|
+ ME-20: Live Support opens WhatsApp to the essential-consts support mobile
|
||||||
|
+ (whatsapp://send?phone=918688182552; no-op when missing).
|
||||||
|
|
||||||
|
[2026-10-24 19:12 IST] web-ui: add /qr-based-download and /qr-download routes (port of info-site qr-download page).
|
||||||
|
Same URLs, same UA-sniff auto-redirect on mount (android -> intent://, ios -> App Store,
|
||||||
|
otherwise stay), same three option cards with the same SVG glyphs and click handlers that
|
||||||
|
assign window.location.href. Shared component so both paths render identically; standalone
|
||||||
|
page (no AppLayout shell). No user-ui counterpart (new web surface, no RN equivalent);
|
||||||
|
no tests (web-ui has no test runner).
|
||||||
|
|
||||||
|
[2026-10-24 19:18 IST] Me hub: move Live Support directly below the Coupons entry
|
||||||
|
(user-ui + web-ui). Same WhatsApp handler, icon and subtitle; only the position changed
|
||||||
|
(Shopping & Activity section, after Coupons) instead of first in Support.
|
||||||
|
|
||||||
|
[2026-10-24 19:20 IST] Me hub Live Support prefills the WhatsApp message with the glimpse's
|
||||||
|
upcoming order ids ("Hi, my orders are <id1>, <id2>\n", URL-encoded as &text=). Same
|
||||||
|
upcoming filter as NextOrderGlimpse (not cancelled/success, in glimpse window); no ids ->
|
||||||
|
opens WhatsApp without text. user-ui uses whatsapp://send, web uses https://wa.me/.
|
||||||
|
|
||||||
|
[2026-10-24 19:26 IST] Drop the trailing newline from the Live Support prefill (message now
|
||||||
|
ends with the last order id). WhatsApp exposes no caret parameter; the trailing newline
|
||||||
|
was the likely cause of the caret landing at position 0 after its whitespace
|
||||||
|
normalization. user-ui + web-ui + ME-20 expectation updated.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue