Skip to content

Commit c1f017e

Browse files
Banyel3claude
andcommitted
fix(customer): create the DB user on auth restore + nicer empty states
- auth: _layout now calls postSession whenever Firebase restores a session, not only on the login-form submit. An account whose first postSession failed (e.g. wrong API URL during setup) was left with a Firebase account but no Postgres row → "User not found" 401 on every screen. Idempotent upsert fixes it on the next reload. - empty states: notifications now uses the friendly EmptyState (🔔) and the saved-addresses empty gets a centered 📍 block, matching the orders "No orders yet" screen — so a brand-new account reads as "nothing here yet", not an error. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a70a9bb commit c1f017e

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

apps/customer-mobile/src/app/_layout.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { useEffect, useState } from 'react';
1313
import { Text as RNText, TextInput as RNTextInput } from 'react-native';
1414
import { SafeAreaProvider } from 'react-native-safe-area-context';
1515
import { colors, font, ToastProvider } from '@wash-and-go/ui';
16+
import { api } from '../lib/api';
1617
import { auth } from '../lib/firebase';
1718

1819
// Base default font so every Text/TextInput inherits Plus Jakarta, not the
@@ -39,6 +40,13 @@ export default function RootLayout() {
3940

4041
useEffect(() => onAuthStateChanged(auth, (u) => setUser(u)), []);
4142

43+
// Ensure the Postgres user row exists whenever Firebase restores a session —
44+
// not just on the login-form submit. Idempotent upsert; without this, an account
45+
// whose first postSession failed (e.g. wrong API URL) 401s on every screen.
46+
useEffect(() => {
47+
if (user) void api.postSession().catch(() => {});
48+
}, [user]);
49+
4250
useEffect(() => {
4351
if (user === undefined) return; // wait for the first auth state
4452
const onLogin = segments[0] === 'login';

apps/customer-mobile/src/app/addresses.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ export default function AddressesScreen() {
105105
<Screen>
106106
<Text style={styles.section}>Your pickup addresses</Text>
107107
{rows.length === 0 ? (
108-
<Muted>No saved addresses yet. Add one below for faster booking.</Muted>
108+
<View style={{ alignItems: 'center', paddingVertical: space.lg, gap: 6 }}>
109+
<Text style={{ fontSize: 34 }}>📍</Text>
110+
<Muted>No saved addresses yet — add one below for faster booking.</Muted>
111+
</View>
109112
) : (
110113
<View style={{ gap: space.sm }}>
111114
{rows.map((a) => (

apps/customer-mobile/src/app/notifications.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Pressable, StyleSheet, Text, View } from 'react-native';
44
import type { NotificationView } from '@wash-and-go/domain';
55
import {
66
Card,
7+
EmptyState,
78
ErrorState,
89
Loading,
910
Muted,
@@ -86,7 +87,11 @@ export default function NotificationsScreen() {
8687
) : null}
8788

8889
{rows.length === 0 ? (
89-
<Muted>No notifications yet. Order updates show up here.</Muted>
90+
<EmptyState
91+
emoji="🔔"
92+
title="No notifications yet"
93+
subtitle="Updates about your orders will show up here."
94+
/>
9095
) : (
9196
<View style={{ gap: space.sm }}>
9297
{rows.map((n) => (

0 commit comments

Comments
 (0)