Skip to content

Commit 097307f

Browse files
authored
removed dashboard and redirect logic (#297)
1 parent b020f86 commit 097307f

3 files changed

Lines changed: 65 additions & 45 deletions

File tree

src/new-landingpage/src/App.tsx

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { useAuth } from "@clerk/clerk-react";
21
import { BrowserRouter, Navigate, Route, Routes } from "react-router-dom";
2+
import type { PropsWithChildren } from "react";
33
import { LANDING_BASENAME } from "./landingRoutes";
44
import NewLandingPageLogin from "./NewLandingPageLogin";
55
import OrganizationOnboarding from "./OrganizationOnboarding";
66
import "./App.css";
7-
import DashboardPage from "./DashboardPage";
87
import { useCookies } from "react-cookie";
98
import LandingPage from "./LandingPage";
109
import {
@@ -13,25 +12,23 @@ import {
1312
LANGFLOW_REFRESH_TOKEN,
1413
} from "./session";
1514

16-
function RootRoute() {
17-
const { isSignedIn } = useAuth();
15+
function SessionRedirect({ children }: PropsWithChildren) {
1816
const [cookies] = useCookies([LANGFLOW_ACCESS_TOKEN, LANGFLOW_REFRESH_TOKEN]);
17+
const workspaceReady = hasWorkspaceSession(cookies);
1918

20-
console.log("[App] RootRoute render", { isSignedIn });
21-
22-
if (isSignedIn) {
23-
const workspaceReady = hasWorkspaceSession(cookies);
24-
const destination = workspaceReady ? "/dashboard" : "/organization";
25-
26-
console.log("[App] Redirecting signed-in user from root", {
27-
workspaceReady,
28-
destination,
29-
});
30-
31-
return <Navigate to={destination} replace />;
19+
if (workspaceReady) {
20+
console.log("[App] SessionRedirect detected workspace; sending to /flows");
21+
window.location.assign("/flows");
22+
return null;
3223
}
3324

34-
return <LandingPage />;
25+
return <>{children}</>;
26+
}
27+
28+
function FlowsRedirect() {
29+
console.log("[App] Redirecting to /flows");
30+
window.location.assign("/flows");
31+
return null;
3532
}
3633

3734
export default function App() {
@@ -40,10 +37,23 @@ export default function App() {
4037
return (
4138
<BrowserRouter basename={LANDING_BASENAME}>
4239
<Routes>
43-
<Route path="/" element={<RootRoute />} />
44-
<Route path="/login" element={<NewLandingPageLogin />} />
45-
<Route path="/organization" element={<OrganizationOnboarding />} />
46-
<Route path="/dashboard" element={<DashboardPage />} />
40+
<Route path="/" element={<LandingPage />} />
41+
<Route
42+
path="/login"
43+
element={
44+
<SessionRedirect>
45+
<NewLandingPageLogin />
46+
</SessionRedirect>
47+
}
48+
/>
49+
<Route
50+
path="/organization"
51+
element={
52+
<SessionRedirect>
53+
<OrganizationOnboarding />
54+
</SessionRedirect>
55+
}
56+
/>
4757
<Route path="*" element={<Navigate to="/" replace />} />
4858
</Routes>
4959
</BrowserRouter>

src/new-landingpage/src/NewLandingPageLogin.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,18 @@ export default function NewLandingPageLogin() {
2626
useEffect(() => {
2727
if (isLoaded && isSignedIn) {
2828
const workspaceReady = hasWorkspaceSession(cookies);
29-
const destination = workspaceReady ? "/dashboard" : "/organization";
29+
const destination = workspaceReady ? "/flows" : "/organization";
3030

3131
console.log(
3232
"[NewLandingPageLogin] User signed in, redirecting based on session",
3333
{ workspaceReady, destination },
3434
);
3535

36+
if (workspaceReady) {
37+
window.location.assign("/flows");
38+
return;
39+
}
40+
3641
navigate(destination, { replace: true });
3742
}
3843
}, [cookies, isLoaded, isSignedIn, navigate]);

src/new-landingpage/src/OrganizationOnboarding.tsx

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import {
1616
} from "react";
1717
import {
1818
Navigate,
19-
useLocation,
20-
useNavigate,
2119
useSearchParams,
2220
} from "react-router-dom";
2321
import { useCookies } from "react-cookie";
@@ -100,10 +98,22 @@ async function requestJson(
10098
});
10199

102100
const text = expectJson ? await response.text() : null;
103-
const data = text ? (JSON.parse(text) as Record<string, any>) : null;
101+
let data: Record<string, any> | null = null;
102+
103+
if (text) {
104+
try {
105+
data = JSON.parse(text) as Record<string, any>;
106+
} catch {
107+
// Non-JSON response (e.g., HTML error page); keep text for fallback messaging
108+
data = null;
109+
}
110+
}
104111

105112
if (!response.ok) {
106-
const detail = (data?.detail as string) ?? response.statusText;
113+
const detail =
114+
(data?.detail as string) ??
115+
(text ? text.slice(0, 200) : null) ??
116+
response.statusText;
107117
throw new HttpError(response.status, detail || "Request failed", data);
108118
}
109119

@@ -228,8 +238,6 @@ export default function OrganizationOnboarding() {
228238
organizationId: organization?.id,
229239
});
230240

231-
const location = useLocation();
232-
const navigate = useNavigate();
233241
const [searchParams, setSearchParams] = useSearchParams();
234242

235243
const [cookies, setCookie, removeCookie] = useCookies([
@@ -241,7 +249,6 @@ export default function OrganizationOnboarding() {
241249
const [error, setError] = useState<string | null>(null);
242250
const [status, setStatus] = useState<string | null>(null);
243251
const [isBootstrapping, setIsBootstrapping] = useState(false);
244-
const [shouldGoToDashboard, setShouldGoToDashboard] = useState(false);
245252

246253
const bootstrappedRef = useRef(false);
247254
const processedOrgRef = useRef<string | null>(null);
@@ -319,13 +326,18 @@ export default function OrganizationOnboarding() {
319326
}
320327
}, [removeCookie, signOut]);
321328

329+
const goToFlows = useCallback(() => {
330+
console.log("[OrganizationOnboarding] Redirecting to /flows");
331+
window.location.assign("/flows");
332+
}, []);
333+
322334
/**
323335
* Core bootstrap flow:
324336
* - createOrganisation
325337
* - ensureLangflowUser
326338
* - backendLogin
327339
* - persist cookies + storage
328-
* - redirect to /dashboard
340+
* - redirect to /flows
329341
*/
330342
const bootstrapSession = useCallback(async () => {
331343
if (!isSignedIn || !organization?.id || bootstrappedRef.current) return;
@@ -367,13 +379,12 @@ export default function OrganizationOnboarding() {
367379

368380
persistSession(orgToken, (tokens as any)?.refresh_token ?? null, activeOrgId);
369381

370-
setStatus("Redirecting to dashboard...");
382+
setStatus("Redirecting to workspace...");
371383
console.log(
372-
"[OrganizationOnboarding] Redirecting to dashboard with org",
384+
"[OrganizationOnboarding] Redirecting to workspace with org",
373385
activeOrgId,
374386
);
375-
setShouldGoToDashboard(true);
376-
navigate("/dashboard", { replace: true });
387+
goToFlows();
377388
} catch (err: any) {
378389
console.error("[OrganizationOnboarding] Failed to bootstrap", err);
379390
const msg =
@@ -391,10 +402,10 @@ export default function OrganizationOnboarding() {
391402
clearSession,
392403
getToken,
393404
isSignedIn,
394-
navigate,
395405
organization?.id,
396406
persistSession,
397407
user,
408+
goToFlows,
398409
]);
399410

400411
useEffect(() => {
@@ -422,17 +433,16 @@ export default function OrganizationOnboarding() {
422433
const hasAccessToken = Boolean(cookies[LANGFLOW_ACCESS_TOKEN]);
423434

424435
if (orgSelected && activeOrgId && hasAccessToken) {
425-
console.log("[OrganizationOnboarding] Session already present; routing to /dashboard", {
436+
console.log("[OrganizationOnboarding] Session already present; routing to /flows", {
426437
activeOrgId,
427438
});
428-
setShouldGoToDashboard(true);
429-
navigate("/dashboard", { replace: true });
439+
goToFlows();
430440
}
431-
}, [cookies, isLoaded, isSignedIn, navigate]);
441+
}, [cookies, goToFlows, isLoaded, isSignedIn]);
432442

433443
/**
434444
* When Clerk redirects back with ?selected=true,
435-
* create org + bootstrap session, then go to /dashboard.
445+
* create org + bootstrap session, then go to /flows.
436446
*/
437447
useEffect(() => {
438448
if (!isLoaded || !isSignedIn) return;
@@ -495,11 +505,6 @@ export default function OrganizationOnboarding() {
495505
return <Navigate to="/login" replace />;
496506
}
497507

498-
if (shouldGoToDashboard) {
499-
console.log("[OrganizationOnboarding] Local redirect flag set; sending to /dashboard");
500-
return <Navigate to="/dashboard" replace />;
501-
}
502-
503508
return (
504509
<>
505510
{showLoadingOverlay && (

0 commit comments

Comments
 (0)