From 7a0a97aea3d4ea0087c80b1739d463a331abc863 Mon Sep 17 00:00:00 2001 From: "groombook-ci[bot]" Date: Sun, 29 Mar 2026 12:44:45 +0000 Subject: [PATCH] fix(setup): add frontend guard to redirect when setup not needed Add a useEffect in SetupWizard that checks GET /api/setup/status on mount. If needsSetup === false, redirect to /admin immediately instead of showing the wizard. Shows a "Checking setup status..." loading state while the check is in flight. Fixes GRO-254 Co-Authored-By: Paperclip --- apps/web/src/pages/SetupWizard.jsx | 32 +++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/apps/web/src/pages/SetupWizard.jsx b/apps/web/src/pages/SetupWizard.jsx index 69ed08d..72fa949 100644 --- a/apps/web/src/pages/SetupWizard.jsx +++ b/apps/web/src/pages/SetupWizard.jsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; import { useNavigate } from "react-router-dom"; import { useBranding } from "../BrandingContext.js"; @@ -17,6 +17,21 @@ export function SetupWizard() { const [businessName, setBusinessName] = useState(""); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); + const [guardLoading, setGuardLoading] = useState(true); + + // Guard: redirect if setup is not needed + useEffect(() => { + fetch("/api/setup/status") + .then((r) => r.json()) + .then((data) => { + if (data.needsSetup === false) { + navigate("/admin", { replace: true }); + } else { + setGuardLoading(false); + } + }) + .catch(() => setGuardLoading(false)); + }, [navigate]); const current = STEPS[step]; const isLast = step === STEPS.length - 1; @@ -61,6 +76,21 @@ export function SetupWizard() { if (step > 0) setStep((s) => s - 1); }; + if (guardLoading) { + return ( +
+

Checking setup status…

+
+ ); + } + return (