From e435fe344eedf36f02b494a40d9b0466c968ff85 Mon Sep 17 00:00:00 2001 From: Flea Flicker Date: Sun, 5 Apr 2026 23:09:43 +0000 Subject: [PATCH] fix(web): clear needsSetup state after OOBE completion to prevent loop When SetupWizard completes POST /api/setup and navigates to /admin, App.tsx still has needsSetup=true in React state, causing an immediate redirect back to /setup. Pass onSetupComplete callback to SetupWizard which clears the state before navigating, breaking the loop. Co-Authored-By: Paperclip --- apps/web/src/App.tsx | 2 +- apps/web/src/pages/SetupWizard.jsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx index 8e8c79e..9fc0d1b 100644 --- a/apps/web/src/App.tsx +++ b/apps/web/src/App.tsx @@ -231,7 +231,7 @@ export function App() { if (location.pathname === "/setup") { return ( - + setNeedsSetup(false)} /> ); } diff --git a/apps/web/src/pages/SetupWizard.jsx b/apps/web/src/pages/SetupWizard.jsx index aaaf269..666b67c 100644 --- a/apps/web/src/pages/SetupWizard.jsx +++ b/apps/web/src/pages/SetupWizard.jsx @@ -2,7 +2,7 @@ import { useState, useEffect } from "react"; import { useNavigate } from "react-router-dom"; import { useBranding } from "../BrandingContext.js"; -export function SetupWizard() { +export function SetupWizard({ onSetupComplete }) { const navigate = useNavigate(); const { refresh: refreshBranding } = useBranding(); @@ -160,6 +160,8 @@ export function SetupWizard() { } // Refresh branding so the nav bar shows the new business name refreshBranding(); + // Clear needsSetup state in App so the redirect to /admin sticks + if (onSetupComplete) onSetupComplete(); } catch (e) { setError("Network error. Please try again."); setLoading(false);