From 10a3304e6a55d4f3b187668aa46127eb0de583c2 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Mon, 23 Feb 2026 20:18:39 -0800 Subject: [PATCH] refactor: simplify onboarding page to use OnboardingForm component --- .../src/app/onboarding/page.tsx | 145 ++---------------- 1 file changed, 9 insertions(+), 136 deletions(-) diff --git a/ui/litellm-dashboard/src/app/onboarding/page.tsx b/ui/litellm-dashboard/src/app/onboarding/page.tsx index 3bdf57907ee..d7840a7be3a 100644 --- a/ui/litellm-dashboard/src/app/onboarding/page.tsx +++ b/ui/litellm-dashboard/src/app/onboarding/page.tsx @@ -1,149 +1,22 @@ "use client"; -import React, { Suspense, useEffect, useState } from "react"; +import React, { Suspense } from "react"; import { useSearchParams } from "next/navigation"; -import { Card, Title, Text, TextInput, Callout, Button, Grid, Col } from "@tremor/react"; -import { RiCheckboxCircleLine } from "@remixicon/react"; -import { - getOnboardingCredentials, - claimOnboardingToken, - getUiConfig, - getProxyBaseUrl, -} from "@/components/networking"; -import { jwtDecode } from "jwt-decode"; -import { Form, Button as Button2 } from "antd"; -import { getCookie } from "@/utils/cookieUtils"; +import { OnboardingForm } from "./OnboardingForm"; function OnboardingContent() { - const [form] = Form.useForm(); const searchParams = useSearchParams()!; - const token = getCookie("token"); - const inviteID = searchParams.get("invitation_id"); const action = searchParams.get("action"); - const [accessToken, setAccessToken] = useState(null); - const [defaultUserEmail, setDefaultUserEmail] = useState(""); - const [userEmail, setUserEmail] = useState(""); - const [userID, setUserID] = useState(null); - const [loginUrl, setLoginUrl] = useState(""); - const [jwtToken, setJwtToken] = useState(""); - const [getUiConfigLoading, setGetUiConfigLoading] = useState(true); - - useEffect(() => { - getUiConfig().then((data) => { - // get the information for constructing the proxy base url, and then set the token and auth loading - console.log("ui config in onboarding.tsx:", data); - setGetUiConfigLoading(false); - }); - }, []); - - useEffect(() => { - if (!inviteID || getUiConfigLoading) { - // wait for the ui config to be loaded - return; - } - - getOnboardingCredentials(inviteID).then((data) => { - const login_url = data.login_url; - console.log("login_url:", login_url); - setLoginUrl(login_url); - - const token = data.token; - const decoded = jwtDecode(token) as { [key: string]: any }; - setJwtToken(token); - - console.log("decoded:", decoded); - setAccessToken(decoded.key); - - console.log("decoded user email:", decoded.user_email); - const user_email = decoded.user_email; - setUserEmail(user_email); - - const user_id = decoded.user_id; - setUserID(user_id); - }); - }, [inviteID, getUiConfigLoading]); - - const handleSubmit = (formValues: Record) => { - console.log("in handle submit. accessToken:", accessToken, "token:", jwtToken, "formValues:", formValues); - if (!accessToken || !jwtToken) { - return; - } - - formValues.user_email = userEmail; - - if (!userID || !inviteID) { - return; - } - claimOnboardingToken(accessToken, inviteID, userID, formValues.password).then((data) => { - // set cookie "token" to jwtToken - document.cookie = "token=" + jwtToken; - - const proxyBaseUrl = getProxyBaseUrl(); - console.log("proxyBaseUrl:", proxyBaseUrl); - - // Construct the full redirect URL using the proxyBaseUrl which includes the server root path - let redirectUrl = proxyBaseUrl ? `${proxyBaseUrl}/ui/?login=success` : "/ui/?login=success"; - console.log("redirecting to:", redirectUrl); - - window.location.href = redirectUrl; - }); - - // redirect to login page - }; - return ( -
- - 🚅 LiteLLM - {action === "reset_password" ? "Reset Password" : "Sign up"} - - {action === "reset_password" - ? "Reset your password to access Admin UI." - : "Claim your user account to login to Admin UI."} - - - {action !== "reset_password" && ( - - - SSO is under the Enterprise Tier. - - - - - - - )} - -
- <> - - - - - - - - - -
- {action === "reset_password" ? "Reset Password" : "Sign Up"} -
-
-
-
- ); + const variant = action === "reset_password" ? "reset_password" : "signup"; + return ; } export default function Onboarding() { return ( - Loading...}> + Loading... + } + > );