diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index dd06ff5..ec2af70 100644 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -14,6 +14,7 @@ import { Route as RedefinirSenhaRouteImport } from './routes/redefinir-senha' import { Route as RecuperarSenhaRouteImport } from './routes/recuperar-senha' import { Route as PainelRouteImport } from './routes/painel' import { Route as LoginRouteImport } from './routes/login' +import { Route as BemVindoRouteImport } from './routes/bem-vindo' import { Route as AdminRouteImport } from './routes/admin' import { Route as IndexRouteImport } from './routes/index' import { Route as PainelIndexRouteImport } from './routes/painel.index' @@ -59,6 +60,11 @@ const LoginRoute = LoginRouteImport.update({ path: '/login', getParentRoute: () => rootRouteImport, } as any) +const BemVindoRoute = BemVindoRouteImport.update({ + id: '/bem-vindo', + path: '/bem-vindo', + getParentRoute: () => rootRouteImport, +} as any) const AdminRoute = AdminRouteImport.update({ id: '/admin', path: '/admin', @@ -158,6 +164,7 @@ const AdminAgenteIdRoute = AdminAgenteIdRouteImport.update({ export interface FileRoutesByFullPath { '/': typeof IndexRoute '/admin': typeof AdminRouteWithChildren + '/bem-vindo': typeof BemVindoRoute '/login': typeof LoginRoute '/painel': typeof PainelRouteWithChildren '/recuperar-senha': typeof RecuperarSenhaRoute @@ -183,6 +190,7 @@ export interface FileRoutesByFullPath { } export interface FileRoutesByTo { '/': typeof IndexRoute + '/bem-vindo': typeof BemVindoRoute '/login': typeof LoginRoute '/recuperar-senha': typeof RecuperarSenhaRoute '/redefinir-senha': typeof RedefinirSenhaRoute @@ -208,6 +216,7 @@ export interface FileRoutesById { __root__: typeof rootRouteImport '/': typeof IndexRoute '/admin': typeof AdminRouteWithChildren + '/bem-vindo': typeof BemVindoRoute '/login': typeof LoginRoute '/painel': typeof PainelRouteWithChildren '/recuperar-senha': typeof RecuperarSenhaRoute @@ -236,6 +245,7 @@ export interface FileRouteTypes { fullPaths: | '/' | '/admin' + | '/bem-vindo' | '/login' | '/painel' | '/recuperar-senha' @@ -261,6 +271,7 @@ export interface FileRouteTypes { fileRoutesByTo: FileRoutesByTo to: | '/' + | '/bem-vindo' | '/login' | '/recuperar-senha' | '/redefinir-senha' @@ -285,6 +296,7 @@ export interface FileRouteTypes { | '__root__' | '/' | '/admin' + | '/bem-vindo' | '/login' | '/painel' | '/recuperar-senha' @@ -312,6 +324,7 @@ export interface FileRouteTypes { export interface RootRouteChildren { IndexRoute: typeof IndexRoute AdminRoute: typeof AdminRouteWithChildren + BemVindoRoute: typeof BemVindoRoute LoginRoute: typeof LoginRoute PainelRoute: typeof PainelRouteWithChildren RecuperarSenhaRoute: typeof RecuperarSenhaRoute @@ -357,6 +370,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof LoginRouteImport parentRoute: typeof rootRouteImport } + '/bem-vindo': { + id: '/bem-vindo' + path: '/bem-vindo' + fullPath: '/bem-vindo' + preLoaderRoute: typeof BemVindoRouteImport + parentRoute: typeof rootRouteImport + } '/admin': { id: '/admin' path: '/admin' @@ -555,6 +575,7 @@ const PainelRouteWithChildren = const rootRouteChildren: RootRouteChildren = { IndexRoute: IndexRoute, AdminRoute: AdminRouteWithChildren, + BemVindoRoute: BemVindoRoute, LoginRoute: LoginRoute, PainelRoute: PainelRouteWithChildren, RecuperarSenhaRoute: RecuperarSenhaRoute, diff --git a/src/routes/painel.index.tsx b/src/routes/painel.index.tsx index 08f6171..2059052 100644 --- a/src/routes/painel.index.tsx +++ b/src/routes/painel.index.tsx @@ -35,13 +35,17 @@ function DashboardPage() { const [wizardOpen, setWizardOpen] = useState(false); const previousStatusRef = useRef(null); - // Auto-open do wizard ao voltar com ?status=success + // Redireciona para /bem-vindo se cliente acabou de pagar e ainda não completou onboarding useEffect(() => { if (search.status !== "success" || !agent) return; if (agent.status === "suspended" || agent.status === "error") { navigate({ search: { status: undefined }, replace: true }); return; } + if (!agent.onboarding_completed) { + navigate({ to: "/bem-vindo", replace: true }); + return; + } if (!agent.telegram_bot_username) setWizardOpen(true); navigate({ search: { status: undefined }, replace: true }); }, [search.status, agent, navigate]); @@ -74,6 +78,17 @@ function DashboardPage() { } const firstName = (profile?.full_name || "").split(" ")[0] || "por aqui"; + const agentName = agent?.agent_name?.trim() || "Mika"; + const statusLabel = + agent?.status === "active" + ? "ativo" + : agent?.status === "provisioning" + ? "sendo preparado" + : agent?.status === "suspended" + ? "pausado" + : agent?.status === "error" + ? "com erro" + : "aguardando configuração"; return (
@@ -83,7 +98,9 @@ function DashboardPage() {

Olá, {firstName} 👋

{subscription - ? "Acompanhe abaixo o status do seu agente Mika." + ? agent + ? <>Seu agente {agentName} está {statusLabel}. + : "Acompanhe abaixo o status do seu agente." : "Vamos colocar seu agente Mika no ar."}