Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions dashboard/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ const Connections = lazyWithRetry(() =>
default: m.Connections,
})),
);
const Onboarding = lazyWithRetry(() =>
import("./components/features/onboarding").then((m) => ({
default: m.Onboarding,
})),
);

// Loading component for lazy-loaded routes
function RouteLoader() {
Expand Down Expand Up @@ -653,6 +658,18 @@ function AppRoutes() {
</AppLayout>
}
/>
{/* Onboarding renders its own slim header inside the sidebar shell,
so it deliberately does NOT wrap with AppLayout. */}
<Route
path="/onboarding"
element={
<ProtectedRoute path="/onboarding">
<Suspense fallback={<RouteLoader />}>
<Onboarding />
</Suspense>
</ProtectedRoute>
}
/>
</Routes>
</BrowserRouter>
);
Expand Down
21 changes: 21 additions & 0 deletions dashboard/src/components/auth/RegisterForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState } from "react";
import { Link, useSearchParams, useNavigate } from "react-router-dom";
import { Eye, EyeOff } from "lucide-react";
import { useQueryClient } from "@tanstack/react-query";
import { Button } from "../ui/button";
import { Input } from "../ui/input";
import { Label } from "../ui/label";
Expand All @@ -13,6 +14,8 @@ import {
CardTitle,
} from "../ui/card";
import { useAuth } from "../../contexts/auth";
import { queryKeys } from "../../api/control-layer/keys";
import type { UserResponse } from "../../api/control-layer/types";
import { toast } from "sonner";

export function RegisterForm() {
Expand All @@ -24,6 +27,7 @@ export function RegisterForm() {
const { register } = useAuth();
const [searchParams] = useSearchParams();
const navigate = useNavigate();
const queryClient = useQueryClient();

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
Expand All @@ -43,9 +47,26 @@ export function RegisterForm() {
password,
displayName: undefined, // Let user set this later
});
// Post-signup landing logic, ordered by priority:
//
// 1. Explicit ?redirect= (e.g. org invite acceptance) — always wins.
// 2. Server-driven onboarding_redirect_url — AuthProvider triggers a
// hard navigation via window.location.href as part of register()'s
// checkAuthStatus() call. We must NOT call navigate() in that case
// or we race the pending hard navigation, briefly mounting the
// wrong route. We detect this by reading the just-populated user
// cache entry that AuthProvider writes before deciding to redirect.
// 3. Otherwise, default to /onboarding for the zero-friction flow.
const redirect = searchParams.get("redirect");
if (redirect) {
navigate(redirect);
} else {
const currentUser = queryClient.getQueryData<UserResponse>(
queryKeys.users.byId("current", "organizations"),
);
if (!currentUser?.onboarding_redirect_url) {
navigate("/onboarding");
}
}
toast.success("Registration successful!");
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/components/features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from "./api-keys";
export * from "./cost-management";
export * from "./endpoints";
export * from "./models";
export * from "./onboarding";
export * from "./playground";
export * from "./profile";
export * from "./requests";
Expand Down
Loading