mirror of
https://github.com/domfelipe/mika-agent-assist.git
synced 2026-08-07 17:56:50 +00:00
Changes
Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
parent
a1f95a4888
commit
8532faecec
2 changed files with 20 additions and 12 deletions
|
|
@ -1,6 +1,8 @@
|
|||
"use client";
|
||||
|
||||
import { createFileRoute, Link } from "@tanstack/react-router";
|
||||
import { zodValidator, fallback } from "@tanstack/zod-adapter";
|
||||
import { z } from "zod";
|
||||
import { useEffect, useState } from "react";
|
||||
import { ArrowRight, CheckCircle2, Loader2, Sparkles } from "lucide-react";
|
||||
import { useSubscription } from "@/hooks/use-profile";
|
||||
|
|
@ -17,10 +19,12 @@ import { TelegramOnboardingWizard } from "@/components/mika/telegram/TelegramOnb
|
|||
import { toast } from "sonner";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const dashboardSearchSchema = z.object({
|
||||
status: fallback(z.string().optional(), undefined),
|
||||
});
|
||||
|
||||
export const Route = createFileRoute("/painel/")({
|
||||
validateSearch: (search: Record<string, unknown>) => ({
|
||||
status: typeof search.status === "string" ? (search.status as string) : undefined,
|
||||
}),
|
||||
validateSearch: zodValidator(dashboardSearchSchema),
|
||||
component: DashboardPage,
|
||||
});
|
||||
|
||||
|
|
@ -36,11 +40,11 @@ function DashboardPage() {
|
|||
useEffect(() => {
|
||||
if (search.status !== "success" || !agent) return;
|
||||
if (agent.status === "suspended" || agent.status === "error") {
|
||||
navigate({ search: {}, replace: true });
|
||||
navigate({ search: { status: undefined }, replace: true });
|
||||
return;
|
||||
}
|
||||
if (!agent.telegram_bot_username) setWizardOpen(true);
|
||||
navigate({ search: {}, replace: true });
|
||||
navigate({ search: { status: undefined }, replace: true });
|
||||
}, [search.status, agent, navigate]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
"use client";
|
||||
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import { zodValidator, fallback } from "@tanstack/zod-adapter";
|
||||
import { z } from "zod";
|
||||
import { Plug } from "lucide-react";
|
||||
import { useEffect } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
|
@ -9,12 +11,14 @@ import { useIntegrationCards } from "@/hooks/use-integrations";
|
|||
import { useAgentInstance } from "@/hooks/use-agent-instance";
|
||||
import { IntegrationCard } from "@/components/mika/integrations/IntegrationCard";
|
||||
|
||||
const integracoesSearchSchema = z.object({
|
||||
status: fallback(z.string().optional(), undefined),
|
||||
error: fallback(z.string().optional(), undefined),
|
||||
mcp: fallback(z.string().optional(), undefined),
|
||||
});
|
||||
|
||||
export const Route = createFileRoute("/painel/integracoes/")({
|
||||
validateSearch: (search: Record<string, unknown>) => ({
|
||||
status: typeof search.status === "string" ? search.status : undefined,
|
||||
error: typeof search.error === "string" ? search.error : undefined,
|
||||
mcp: typeof search.mcp === "string" ? search.mcp : undefined,
|
||||
}),
|
||||
validateSearch: zodValidator(integracoesSearchSchema),
|
||||
component: IntegracoesPage,
|
||||
});
|
||||
|
||||
|
|
@ -31,10 +35,10 @@ function IntegracoesPage() {
|
|||
toast.success(`${search.mcp} conectado com sucesso!`);
|
||||
queryClient.invalidateQueries({ queryKey: ["user-integrations"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["user-integration-limits"] });
|
||||
navigate({ to: "/painel/integracoes", search: {}, replace: true });
|
||||
navigate({ to: "/painel/integracoes", search: { status: undefined, error: undefined, mcp: undefined }, replace: true });
|
||||
} else if (search.error) {
|
||||
toast.error(`Erro ao conectar: ${search.error}`);
|
||||
navigate({ to: "/painel/integracoes", search: {}, replace: true });
|
||||
navigate({ to: "/painel/integracoes", search: { status: undefined, error: undefined, mcp: undefined }, replace: true });
|
||||
}
|
||||
}, [search.status, search.error, search.mcp, navigate, queryClient]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue