enh
This commit is contained in:
parent
934b9f4caf
commit
1259effa5b
4 changed files with 90 additions and 17 deletions
|
|
@ -10,6 +10,7 @@ import { useAddressStore } from '@/src/store/addressStore';
|
|||
import { useRegion } from '@/src/hooks/useRegion';
|
||||
import { confirmRegionSwitch } from '@/src/lib/region-switch';
|
||||
import { useSlots } from '@/src/hooks/prominent-api-hooks';
|
||||
import LocationBar from '@/src/components/LocationBar';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
interface QuickDeliveryAddressSelectorProps {
|
||||
|
|
@ -151,18 +152,23 @@ const QuickDeliveryAddressSelector: React.FC<QuickDeliveryAddressSelectorProps>
|
|||
<>
|
||||
|
||||
{isForFlashDelivery && (
|
||||
<View style={tw`flex-row items-center mb-1`}>
|
||||
<MyTouchableOpacity
|
||||
onPress={() => router.back()}
|
||||
style={tw`p-2 -ml-2`}
|
||||
activeOpacity={0.7}
|
||||
>
|
||||
<MaterialIcons name="chevron-left" size={24} color="#f81260" />
|
||||
</MyTouchableOpacity>
|
||||
<MyText style={[tw`text-lg font-bold ml-2`, { color: '#f81260' }]}>
|
||||
Delivery in within 1 hour
|
||||
</MyText>
|
||||
</View>
|
||||
<>
|
||||
<View style={tw`flex-row items-center px-4 pt-2`}>
|
||||
<MyTouchableOpacity
|
||||
onPress={() => router.back()}
|
||||
style={tw`p-2 -ml-2`}
|
||||
activeOpacity={0.7}
|
||||
>
|
||||
<MaterialIcons name="chevron-left" size={24} color="#f81260" />
|
||||
</MyTouchableOpacity>
|
||||
<MyText style={[tw`text-lg font-bold ml-2`, { color: '#f81260' }]}>
|
||||
Delivery in within 1 hour
|
||||
</MyText>
|
||||
</View>
|
||||
|
||||
{/* Address selector: full-width, right under the header. */}
|
||||
<LocationBar />
|
||||
</>
|
||||
)}
|
||||
|
||||
{!isForFlashDelivery && (
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import { useRouter, usePathname } from 'expo-router';
|
|||
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
|
||||
import { tw, theme, MyText, MyTouchableOpacity, MyFlatList, AppContainer, MiniQuantifier, SearchBar } from 'common-ui';
|
||||
import { trpc } from '@/src/trpc-client';
|
||||
import LocationBar from '@/src/components/LocationBar';
|
||||
import { useAllProducts, useStores, useSlots } from '@/src/hooks/prominent-api-hooks';
|
||||
import { AllProductsApiType } from '@backend/trpc/router';
|
||||
import { useQuickDeliveryStore } from '@/src/store/quickDeliveryStore';
|
||||
|
|
@ -183,7 +182,12 @@ export function SlotLayout({ slotId, storeId, baseUrl, isForFlashDelivery }: Slo
|
|||
|
||||
return (
|
||||
<>
|
||||
<View style={tw` w-full flex-row bg-white px-4 py-2 mb-1`}>
|
||||
<View
|
||||
style={[
|
||||
tw`w-full bg-white`,
|
||||
isForFlashDelivery ? tw`pb-1` : tw`flex-row px-4 py-2 mb-1`,
|
||||
]}
|
||||
>
|
||||
<QuickDeliveryAddressSelector
|
||||
slotId={Number(slotId)}
|
||||
onSlotChange={handleSlotChange}
|
||||
|
|
@ -520,7 +524,6 @@ export function FlashDeliveryProducts({ storeId:storeIdParent, baseUrl, onProduc
|
|||
numColumns={2}
|
||||
ListHeaderComponent={
|
||||
<View style={tw`px-4 pt-2`}>
|
||||
<LocationBar />
|
||||
<SearchBar
|
||||
value={searchQuery}
|
||||
onChangeText={setSearchQuery}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
import React, { useCallback, useRef, useState } from 'react'
|
||||
import { View, ScrollView, ActivityIndicator } from 'react-native'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useRouter, usePathname } from 'expo-router'
|
||||
import MaterialIcons from '@expo/vector-icons/MaterialIcons'
|
||||
import { MyText, MyTouchableOpacity, tw, theme } from 'common-ui'
|
||||
import { MyText, MyTouchableOpacity, tw, theme, StorageServiceCasual } from 'common-ui'
|
||||
import { trpc } from '@/src/trpc-client'
|
||||
import { useAuthOptional } from '@/src/contexts/AuthContext'
|
||||
import type { RedirectState } from '@/src/contexts/AuthContext'
|
||||
import constants from '@/src/constants'
|
||||
import { confirmRegionSwitch } from '@/src/lib/region-switch'
|
||||
import AddressForm from '@/src/components/AddressForm'
|
||||
|
||||
|
|
@ -49,14 +52,34 @@ interface LocationFallbackFlowProps {
|
|||
const LocationFallbackFlow: React.FC<LocationFallbackFlowProps> = ({ onClose, notice, onOpenSettings }) => {
|
||||
const queryClient = useQueryClient()
|
||||
const utils = trpc.useUtils()
|
||||
const router = useRouter()
|
||||
const pathname = usePathname()
|
||||
const auth = useAuthOptional()
|
||||
const isAuthenticated = auth?.isAuthenticated ?? false
|
||||
const isAuthLoading = auth?.isLoading ?? false
|
||||
|
||||
const [mode, setMode] = useState<'choose' | 'add'>('choose')
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [message, setMessage] = useState<string | null>(null)
|
||||
const resolvedRef = useRef<ResolvedRegion | null>(null)
|
||||
|
||||
// Signed out: their saved addresses live behind the account. Remember where we
|
||||
// are so login returns here (same contract LoginWall / useAuthenticatedRoute
|
||||
// use), then the addresses load automatically.
|
||||
const handleLogin = useCallback(async () => {
|
||||
const redirectState: RedirectState = {
|
||||
targetUrl: pathname,
|
||||
queryParams: {},
|
||||
timestamp: Date.now(),
|
||||
}
|
||||
try {
|
||||
await StorageServiceCasual.setItem(constants.AUTH_REDIRECT_KEY, JSON.stringify(redirectState))
|
||||
} catch {
|
||||
// ignore storage failure — still navigate to login
|
||||
}
|
||||
router.push('/(auth)/login')
|
||||
}, [pathname, router])
|
||||
|
||||
const addressesQuery = trpc.user.address.getUserAddresses.useQuery(undefined, {
|
||||
enabled: isAuthenticated,
|
||||
})
|
||||
|
|
@ -216,7 +239,7 @@ const LocationFallbackFlow: React.FC<LocationFallbackFlowProps> = ({ onClose, no
|
|||
</View>
|
||||
)}
|
||||
|
||||
<ScrollView contentContainerStyle={tw`px-5 pb-10`}>
|
||||
<ScrollView style={tw`flex-1`} contentContainerStyle={tw`px-5 pb-10`}>
|
||||
{isAuthenticated &&
|
||||
addresses.map((address) => (
|
||||
<View
|
||||
|
|
@ -263,6 +286,22 @@ const LocationFallbackFlow: React.FC<LocationFallbackFlowProps> = ({ onClose, no
|
|||
</MyTouchableOpacity>
|
||||
</ScrollView>
|
||||
|
||||
{!isAuthenticated && !isAuthLoading && (
|
||||
<View style={tw`px-5 pt-3 pb-6 border-t border-gray-100 bg-white`}>
|
||||
<MyText style={tw`text-gray-500 text-sm text-center mb-3`}>
|
||||
Login to get existing addresses.
|
||||
</MyText>
|
||||
<MyTouchableOpacity
|
||||
testID="location-login"
|
||||
onPress={handleLogin}
|
||||
activeOpacity={0.85}
|
||||
style={tw`bg-brand500 py-3 rounded-xl items-center`}
|
||||
>
|
||||
<MyText style={tw`text-white font-bold`}>Login</MyText>
|
||||
</MyTouchableOpacity>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{busy && (
|
||||
<View style={tw`absolute inset-0 bg-black/20 items-center justify-center`}>
|
||||
<ActivityIndicator size="large" color={theme.colors.brand500} />
|
||||
|
|
|
|||
|
|
@ -4129,3 +4129,28 @@ user-ui
|
|||
(possibly elevated) global store is no longer treated as global by the tag/combo guards.
|
||||
Reviews deliberately left as-is (regional admins still can't see global products' reviews).
|
||||
No dependency added. No migration. No tests run.
|
||||
|
||||
2026-10-14 00:18:25 Flash delivery: move the address selector under the header.
|
||||
apps/user-ui/components/QuickDeliveryAddressSelector.tsx: the flash branch now renders the
|
||||
LocationBar (address selector) directly under the "Delivery in within 1 hour" row, full width.
|
||||
apps/user-ui/components/SlotSpecificView.tsx:
|
||||
+ SlotLayout header wrapper is a column for flash (was flex-row + px-4) so the title and the
|
||||
address bar stack; the title row carries its own px-4 to keep its inset.
|
||||
+ removed the LocationBar (and its import) from FlashDeliveryProducts' ListHeaderComponent —
|
||||
the address now appears once, in the header; the search bar stays in the list header.
|
||||
No dependency added. No migration. No tests run.
|
||||
|
||||
2026-10-14 00:27:03 Location gate: offer login for existing addresses when signed out.
|
||||
apps/user-ui/src/components/location/LocationFallbackFlow.tsx: the choose view now shows a
|
||||
"Login to get existing addresses." banner with a Login button when the user is signed out
|
||||
(and auth has settled). Tapping it stores the auth redirect target (same
|
||||
constants.AUTH_REDIRECT_KEY contract LoginWall uses) and pushes /(auth)/login, so login
|
||||
returns to the current screen and the saved addresses become selectable.
|
||||
No dependency added. No migration. No tests run.
|
||||
|
||||
2026-10-14 00:31:00 Location gate: pin the login prompt to the bottom.
|
||||
apps/user-ui/src/components/location/LocationFallbackFlow.tsx: moved the "Login to get existing
|
||||
addresses." message + Login button out of the top banner into a bottom-pinned block (full-width
|
||||
button, top border); the address list ScrollView is now flex-1 so it scrolls between the header
|
||||
and the bottom block.
|
||||
No dependency added. No migration. No tests run.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue