Prettier format pending files
This commit is contained in:
parent
9703824bbc
commit
be92cde92a
3 changed files with 71 additions and 17 deletions
|
|
@ -305,7 +305,9 @@ export default function Dashboard() {
|
|||
console.log("User and profile exist, loading dashboard data");
|
||||
loadDashboardData();
|
||||
} else if (user && !profile) {
|
||||
console.log("User exists but no profile, showing message (not redirecting)");
|
||||
console.log(
|
||||
"User exists but no profile, showing message (not redirecting)",
|
||||
);
|
||||
setIsLoading(false);
|
||||
}
|
||||
}, [user, profile, authLoading]);
|
||||
|
|
@ -579,7 +581,9 @@ export default function Dashboard() {
|
|||
return (
|
||||
<div className="min-h-screen bg-gray-900 flex items-center justify-center">
|
||||
<div className="max-w-md text-center">
|
||||
<h1 className="text-3xl font-bold text-white mb-4">Welcome to AeThex</h1>
|
||||
<h1 className="text-3xl font-bold text-white mb-4">
|
||||
Welcome to AeThex
|
||||
</h1>
|
||||
<p className="text-gray-400 mb-8">
|
||||
You need to be signed in to access the dashboard
|
||||
</p>
|
||||
|
|
@ -599,7 +603,9 @@ export default function Dashboard() {
|
|||
return (
|
||||
<div className="min-h-screen bg-gray-900 flex items-center justify-center">
|
||||
<div className="max-w-md text-center">
|
||||
<h1 className="text-3xl font-bold text-white mb-4">Complete Your Profile</h1>
|
||||
<h1 className="text-3xl font-bold text-white mb-4">
|
||||
Complete Your Profile
|
||||
</h1>
|
||||
<p className="text-gray-400 mb-8">
|
||||
Let's set up your profile to get started with AeThex
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
## Problem
|
||||
|
||||
You reported that:
|
||||
|
||||
1. After logging in, you get redirected to onboarding unexpectedly
|
||||
2. Site shows you as "logged in" on initial page load but with incomplete profile
|
||||
3. Users shouldn't appear logged in without a complete profile
|
||||
|
|
@ -27,32 +28,35 @@ You reported that:
|
|||
**File:** `code/client/pages/Dashboard.tsx` (Lines 283-311)
|
||||
|
||||
**What changed:**
|
||||
|
||||
- ❌ **REMOVED:** Code that auto-redirected to `/onboarding` when no user
|
||||
- ❌ **REMOVED:** Comment saying "redirect to login when auth is resolved"
|
||||
- ✅ **ADDED:** Simple state handling without redirects
|
||||
- ✅ **ADDED:** Clear separation of auth loading vs auth resolved states
|
||||
|
||||
**Old behavior:**
|
||||
|
||||
```typescript
|
||||
if (!user && !authLoading) {
|
||||
navigate("/onboarding", { replace: true }); // AUTO-REDIRECT!
|
||||
navigate("/onboarding", { replace: true }); // AUTO-REDIRECT!
|
||||
}
|
||||
```
|
||||
|
||||
**New behavior:**
|
||||
|
||||
```typescript
|
||||
if (authLoading) {
|
||||
setIsLoading(true); // Show loading state
|
||||
setIsLoading(true); // Show loading state
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
setIsLoading(false); // Auth resolved, no user
|
||||
setIsLoading(false); // Auth resolved, no user
|
||||
return;
|
||||
}
|
||||
|
||||
if (user && profile) {
|
||||
loadDashboardData(); // Load dashboard data
|
||||
loadDashboardData(); // Load dashboard data
|
||||
}
|
||||
```
|
||||
|
||||
|
|
@ -63,6 +67,7 @@ if (user && profile) {
|
|||
**File:** `code/client/pages/Dashboard.tsx` (Lines 566-602)
|
||||
|
||||
**What changed:**
|
||||
|
||||
- ❌ **REMOVED:** `return null` when no user (which allowed redirect to happen)
|
||||
- ✅ **ADDED:** "Please Sign In" message with button
|
||||
- ✅ **ADDED:** "Complete Your Profile" message with button
|
||||
|
|
@ -71,6 +76,7 @@ if (user && profile) {
|
|||
**New behavior:**
|
||||
|
||||
**When not logged in:**
|
||||
|
||||
```
|
||||
┌─────────────────────────┐
|
||||
│ Welcome to AeThex │
|
||||
|
|
@ -84,6 +90,7 @@ if (user && profile) {
|
|||
```
|
||||
|
||||
**When logged in but profile incomplete:**
|
||||
|
||||
```
|
||||
┌─────────────────────────┐
|
||||
│ Complete Your Profile │
|
||||
|
|
@ -97,6 +104,7 @@ if (user && profile) {
|
|||
```
|
||||
|
||||
**When logged in with complete profile:**
|
||||
|
||||
- Full dashboard shown normally
|
||||
|
||||
---
|
||||
|
|
@ -106,11 +114,13 @@ if (user && profile) {
|
|||
### Scenario 1: Logging In
|
||||
|
||||
**Before:**
|
||||
|
||||
1. Enter email/password
|
||||
2. Submit
|
||||
3. ❌ Redirected to onboarding (confusing!)
|
||||
|
||||
**After:**
|
||||
|
||||
1. Enter email/password
|
||||
2. Submit
|
||||
3. ✅ See dashboard or "Complete Profile" message
|
||||
|
|
@ -121,11 +131,13 @@ if (user && profile) {
|
|||
### Scenario 2: Page Reload While Logged In
|
||||
|
||||
**Before:**
|
||||
|
||||
1. Reload page
|
||||
2. ❌ See yourself "logged in" for a moment
|
||||
3. ❌ Maybe get redirected to onboarding
|
||||
|
||||
**After:**
|
||||
|
||||
1. Reload page
|
||||
2. ✅ See loading state briefly
|
||||
3. ✅ Dashboard appears or message about completing profile
|
||||
|
|
@ -136,10 +148,12 @@ if (user && profile) {
|
|||
### Scenario 3: Visiting Dashboard When Not Logged In
|
||||
|
||||
**Before:**
|
||||
|
||||
1. Visit `/dashboard` without being logged in
|
||||
2. ❌ Redirected to onboarding (wrong!)
|
||||
|
||||
**After:**
|
||||
|
||||
1. Visit `/dashboard` without being logged in
|
||||
2. ✅ See "Please Sign In" message
|
||||
3. ✅ Click button to go to login page
|
||||
|
|
@ -149,19 +163,23 @@ if (user && profile) {
|
|||
## What This Means
|
||||
|
||||
✅ **No more mysterious redirects**
|
||||
|
||||
- You won't be auto-redirected to onboarding unexpectedly
|
||||
- Your destination is clear (dashboard or complete profile)
|
||||
|
||||
✅ **No confusing "logged in by default" state**
|
||||
|
||||
- Loading spinner shows while profile is being fetched
|
||||
- You don't see yourself logged in until profile is actually loaded
|
||||
|
||||
✅ **User control over onboarding**
|
||||
|
||||
- You choose when to complete your profile
|
||||
- Not forced by automatic redirects
|
||||
- Clear button to start onboarding
|
||||
|
||||
✅ **Clear error messages**
|
||||
|
||||
- "Sign In" message when not authenticated
|
||||
- "Complete Profile" message when missing profile data
|
||||
- No guessing what state you're in
|
||||
|
|
@ -171,6 +189,7 @@ if (user && profile) {
|
|||
## Testing the Fix
|
||||
|
||||
### Test 1: Log In and Go to Dashboard
|
||||
|
||||
1. Visit `/login`
|
||||
2. Sign in with email/password
|
||||
3. **Expected:** Should see dashboard or "Complete Profile" message
|
||||
|
|
@ -178,6 +197,7 @@ if (user && profile) {
|
|||
5. **If profile incomplete:** Click "Complete Profile" button intentionally
|
||||
|
||||
### Test 2: Reload Dashboard While Logged In
|
||||
|
||||
1. Log in successfully
|
||||
2. Visit `/dashboard`
|
||||
3. Reload page (F5 or Ctrl+R)
|
||||
|
|
@ -185,12 +205,14 @@ if (user && profile) {
|
|||
5. **NOT expected:** Redirect to onboarding or seeing "logged in by default"
|
||||
|
||||
### Test 3: Visit Dashboard When Not Logged In
|
||||
|
||||
1. Make sure you're logged out (go to `/logout` or clear cookies)
|
||||
2. Visit `/dashboard`
|
||||
3. **Expected:** See "Please Sign In" message with button
|
||||
4. **NOT expected:** Redirect to onboarding
|
||||
|
||||
### Test 4: Sign Out and Back In
|
||||
|
||||
1. While on dashboard, click Sign Out
|
||||
2. **Expected:** Should see "Please Sign In" message
|
||||
3. Click Sign In button
|
||||
|
|
@ -202,8 +224,8 @@ if (user && profile) {
|
|||
|
||||
## Files Modified
|
||||
|
||||
| File | Changes | Status |
|
||||
|------|---------|--------|
|
||||
| File | Changes | Status |
|
||||
| --------------------------------- | ------------------------------------------- | -------- |
|
||||
| `code/client/pages/Dashboard.tsx` | Removed auto-redirect logic (lines 283-311) | ✅ FIXED |
|
||||
| `code/client/pages/Dashboard.tsx` | Added proper state messages (lines 566-602) | ✅ FIXED |
|
||||
|
||||
|
|
@ -212,6 +234,7 @@ if (user && profile) {
|
|||
## Architecture Changes
|
||||
|
||||
**Before:**
|
||||
|
||||
```
|
||||
User logs in
|
||||
↓
|
||||
|
|
@ -223,6 +246,7 @@ User redirected unexpectedly
|
|||
```
|
||||
|
||||
**After:**
|
||||
|
||||
```
|
||||
User logs in
|
||||
↓
|
||||
|
|
@ -252,16 +276,19 @@ User sees clear message, no redirects
|
|||
## Potential Issues to Watch For
|
||||
|
||||
### If you're still seeing redirects:
|
||||
|
||||
1. Clear browser cache (Ctrl+Shift+Delete)
|
||||
2. Hard refresh the page (Ctrl+Shift+R)
|
||||
3. Make sure you deployed the latest code
|
||||
|
||||
### If messages don't appear:
|
||||
|
||||
1. Check browser console (F12) for errors
|
||||
2. Verify Dashboard.tsx was updated correctly
|
||||
3. Check that you're seeing the new Dashboard code
|
||||
|
||||
### If onboarding still appears:
|
||||
|
||||
1. It should only appear if you click "Complete Profile"
|
||||
2. Check that auto-redirect code was removed
|
||||
3. Verify changes to lines 283-311 and 566-602
|
||||
|
|
@ -280,6 +307,7 @@ User sees clear message, no redirects
|
|||
## Questions?
|
||||
|
||||
Refer to:
|
||||
|
||||
1. **LOGIN-ONBOARDING-REDIRECT-ANALYSIS.md** - Detailed root cause analysis
|
||||
2. Browser console (F12) - Check for error messages
|
||||
3. Network tab (F12 → Network) - Check what endpoints are being called
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
## Problem Statement
|
||||
|
||||
User reports:
|
||||
|
||||
1. After logging in, they get redirected to onboarding
|
||||
2. When first loading the site, it shows them as "logged in" but with incomplete profile
|
||||
3. Frustrated because users shouldn't be shown as logged in without a complete profile
|
||||
|
|
@ -15,6 +16,7 @@ User reports:
|
|||
### Issue 1: Session Restoration Before Profile Completion Check
|
||||
|
||||
**What happens:**
|
||||
|
||||
1. User logs in successfully
|
||||
2. Session cookies are set by Supabase
|
||||
3. Page reloads or user navigates
|
||||
|
|
@ -25,6 +27,7 @@ User reports:
|
|||
8. Once profile loads, if incomplete, they might be redirected
|
||||
|
||||
**Why it's confusing:**
|
||||
|
||||
- User sees themselves logged in
|
||||
- But profile might still be loading
|
||||
- Then get redirected to onboarding
|
||||
|
|
@ -36,12 +39,14 @@ User reports:
|
|||
|
||||
**What's happening:**
|
||||
The AuthContext loads the session from browser storage immediately:
|
||||
|
||||
- Supabase session stored in cookies/IndexedDB
|
||||
- On page load, `onAuthStateChange` fires with existing session
|
||||
- User state is set
|
||||
- UI shows user as authenticated
|
||||
|
||||
**But:**
|
||||
|
||||
- Profile data takes time to load from database
|
||||
- UI briefly shows "logged in" before profile is available
|
||||
- This can feel like users are logged in "by default"
|
||||
|
|
@ -51,6 +56,7 @@ The AuthContext loads the session from browser storage immediately:
|
|||
### Issue 3: Onboarding Redirect Logic
|
||||
|
||||
**Current logic in Dashboard.tsx (line 291):**
|
||||
|
||||
```typescript
|
||||
if (!user && !authLoading) {
|
||||
navigate("/onboarding", { replace: true });
|
||||
|
|
@ -58,6 +64,7 @@ if (!user && !authLoading) {
|
|||
```
|
||||
|
||||
**Issues with this:**
|
||||
|
||||
1. Redirects to onboarding if NO user
|
||||
2. But never checks if profile is INCOMPLETE
|
||||
3. Should either:
|
||||
|
|
@ -71,11 +78,13 @@ if (!user && !authLoading) {
|
|||
**Current behavior is confusing because:**
|
||||
|
||||
1. **Mixed signals:**
|
||||
|
||||
- User sees themselves logged in
|
||||
- Then gets redirected to onboarding
|
||||
- Feels like auth is broken
|
||||
|
||||
2. **No clear intent:**
|
||||
|
||||
- Onboarding is meant to COMPLETE the profile
|
||||
- But if you're already logged in, you should be on dashboard
|
||||
- Redirect should only happen if profile is incomplete
|
||||
|
|
@ -93,13 +102,15 @@ if (!user && !authLoading) {
|
|||
|
||||
**Current:** Line 291-295 in Dashboard.tsx checks `if (!user)` and redirects
|
||||
|
||||
**Should be:**
|
||||
**Should be:**
|
||||
|
||||
- If no user → stay on dashboard (it handles showing loading state)
|
||||
- If user but profile incomplete → show a prompt, don't redirect
|
||||
- If user and profile complete → show full dashboard
|
||||
|
||||
**Change:**
|
||||
Remove the automatic redirect to onboarding. Instead:
|
||||
|
||||
- Let Dashboard render
|
||||
- Show a "Complete Your Profile" banner if profile is incomplete
|
||||
- Let user click to go to onboarding, don't force redirect
|
||||
|
|
@ -111,6 +122,7 @@ Remove the automatic redirect to onboarding. Instead:
|
|||
**Current:** Session restored from cookies → UI shows user as logged in immediately
|
||||
|
||||
**Should be:**
|
||||
|
||||
- Show loading state while profile is being fetched
|
||||
- Don't show user as "logged in" until profile is loaded
|
||||
- Once profile loads, show actual dashboard
|
||||
|
|
@ -125,11 +137,13 @@ Ensure `loading` state is true while profile is being fetched, then show Loading
|
|||
**Current:** Onboarding shows up unexpectedly after login
|
||||
|
||||
**Should be:**
|
||||
|
||||
- Onboarding only when INTENTIONALLY started (user clicks "Complete Profile")
|
||||
- Not automatically triggered by auth state
|
||||
- Dashboard can show "Profile incomplete" message with link to onboarding
|
||||
|
||||
**Change:**
|
||||
|
||||
- Remove auto-redirect logic
|
||||
- Let Dashboard handle incomplete profile display
|
||||
- User explicitly chooses to complete profile
|
||||
|
|
@ -141,13 +155,14 @@ Ensure `loading` state is true while profile is being fetched, then show Loading
|
|||
### In code/client/pages/Dashboard.tsx (Lines 283-311)
|
||||
|
||||
**Current (WRONG):**
|
||||
|
||||
```typescript
|
||||
useEffect(() => {
|
||||
if (!user && !authLoading) {
|
||||
navigate("/onboarding", { replace: true });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (user && profile) {
|
||||
loadDashboardData();
|
||||
}
|
||||
|
|
@ -155,11 +170,12 @@ useEffect(() => {
|
|||
```
|
||||
|
||||
**Should be:**
|
||||
|
||||
```typescript
|
||||
useEffect(() => {
|
||||
// Don't auto-redirect to onboarding
|
||||
// Let Dashboard render and handle missing profile gracefully
|
||||
|
||||
|
||||
if (user && profile) {
|
||||
loadDashboardData();
|
||||
}
|
||||
|
|
@ -171,6 +187,7 @@ useEffect(() => {
|
|||
### In code/client/pages/Dashboard.tsx (Top level)
|
||||
|
||||
**Add this check:**
|
||||
|
||||
```typescript
|
||||
// If loading, show loading state
|
||||
if (authLoading) {
|
||||
|
|
@ -212,6 +229,7 @@ if (!profile) {
|
|||
## Expected Behavior After Fix
|
||||
|
||||
### Scenario 1: Fresh Login
|
||||
|
||||
1. User logs in with email/password
|
||||
2. Redirected to dashboard
|
||||
3. Dashboard shows loading state while profile is fetched
|
||||
|
|
@ -220,6 +238,7 @@ if (!profile) {
|
|||
- If profile incomplete → show "Complete Your Profile" banner with link to onboarding
|
||||
|
||||
### Scenario 2: Page Reload While Logged In
|
||||
|
||||
1. User is logged in, page reloads
|
||||
2. Supabase session restored from cookies
|
||||
3. AuthContext restores user and fetches profile
|
||||
|
|
@ -227,6 +246,7 @@ if (!profile) {
|
|||
5. Once profile loaded → show dashboard (complete or with banner)
|
||||
|
||||
### Scenario 3: Not Logged In
|
||||
|
||||
1. Unauthenticated user visits `/dashboard`
|
||||
2. Dashboard detects no user
|
||||
3. Shows "Please sign in" message
|
||||
|
|
@ -253,11 +273,11 @@ After implementing fixes:
|
|||
|
||||
## Files to Update
|
||||
|
||||
| File | Lines | Change |
|
||||
|------|-------|--------|
|
||||
| `code/client/pages/Dashboard.tsx` | 283-311 | Remove onboarding redirect |
|
||||
| File | Lines | Change |
|
||||
| --------------------------------- | --------------- | ----------------------------- |
|
||||
| `code/client/pages/Dashboard.tsx` | 283-311 | Remove onboarding redirect |
|
||||
| `code/client/pages/Dashboard.tsx` | Start of render | Add loading/auth state checks |
|
||||
| `code/client/pages/Dashboard.tsx` | TBD | Add "Complete Profile" banner |
|
||||
| `code/client/pages/Dashboard.tsx` | TBD | Add "Complete Profile" banner |
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -273,7 +293,7 @@ After implementing fixes:
|
|||
|
||||
## Related Issues
|
||||
|
||||
- AuthContext clearing session on page load: ✅ FIXED (preserves sb-* keys)
|
||||
- AuthContext clearing session on page load: ✅ FIXED (preserves sb-\* keys)
|
||||
- Session persistence: ✅ WORKING (cookies restored correctly)
|
||||
- Profile loading timing: ⚠️ CAUSES UI CONFUSION (session shown before profile)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue