From e1f00aad9961ffeefecafd0fc7b239f7e17c5519 Mon Sep 17 00:00:00 2001 From: shafi54 <108669266+shafi-aviz@users.noreply.github.com> Date: Wed, 14 Oct 2026 01:03:51 +0530 Subject: [PATCH] enh --- .../location/LocationFallbackFlow.tsx | 52 ++++++++++--------- change-log.txt | 11 ++++ 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/apps/user-ui/src/components/location/LocationFallbackFlow.tsx b/apps/user-ui/src/components/location/LocationFallbackFlow.tsx index 833674a..9106d52 100644 --- a/apps/user-ui/src/components/location/LocationFallbackFlow.tsx +++ b/apps/user-ui/src/components/location/LocationFallbackFlow.tsx @@ -1,15 +1,13 @@ -import React, { useCallback, useRef, useState } from 'react' +import React, { useCallback, useEffect, 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, StorageServiceCasual } from 'common-ui' +import { MyText, MyTouchableOpacity, tw, theme } 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' +import Login from '@/app/(auth)/login' type ResolvedRegion = { regionId: number; boundId: number | null } @@ -52,33 +50,21 @@ interface LocationFallbackFlowProps { const LocationFallbackFlow: React.FC = ({ 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 [mode, setMode] = useState<'choose' | 'add' | 'login'>('choose') const [busy, setBusy] = useState(false) const [message, setMessage] = useState(null) const resolvedRef = useRef(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]) + // The gate renders outside the root navigator (see LocationTestWrapper), so we + // cannot router.push to /login here — render the login screen in place. Once + // auth lands, return to the address chooser with the saved addresses loaded. + useEffect(() => { + if (isAuthenticated && mode === 'login') setMode('choose') + }, [isAuthenticated, mode]) const addressesQuery = trpc.user.address.getUserAddresses.useQuery(undefined, { enabled: isAuthenticated, @@ -171,6 +157,22 @@ const LocationFallbackFlow: React.FC = ({ onClose, no onClose?.() }, [activate, onClose]) + if (mode === 'login') { + return ( + + + setMode('choose')} + activeOpacity={0.7} + style={tw`absolute left-4 top-14 w-10 h-10 rounded-full bg-white/90 items-center justify-center shadow`} + > + + + + ) + } + if (mode === 'add') { return ( @@ -293,7 +295,7 @@ const LocationFallbackFlow: React.FC = ({ onClose, no setMode('login')} activeOpacity={0.85} style={tw`bg-brand500 py-3 rounded-xl items-center`} > diff --git a/change-log.txt b/change-log.txt index 02a507b..58c195b 100644 --- a/change-log.txt +++ b/change-log.txt @@ -4154,3 +4154,14 @@ user-ui 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. + +2026-10-14 00:58:32 Fix: the gate's Login button did nothing. + Root cause: LocationTestWrapper renders the gate INSTEAD of its children, so while the gate is up + the root (the expo-router navigator) is unmounted and router.push is a no-op (the error + is hidden by LogBox.ignoreAllLogs). Same reason FirstUserWrapper only uses local state. + apps/user-ui/src/components/location/LocationFallbackFlow.tsx: + + added a 'login' mode that renders the (router-free) login screen inline, with a back button + + the Login button now switches mode instead of calling router.push; when auth flips to + authenticated the flow returns to the choose view and the saved addresses load + + dropped the now-unused router/pathname/redirect-state imports + No dependency added. No migration. No tests run.