mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-07-17 14:48:48 +02:00
Add Inicio dashboard as homepage
Stat cards (gasto del ciclo, próximas cuotas Tasa Cero, pensión), ask-the-assistant box that lands in Asistente and auto-sends via agent.addMessage + runAgent, and últimas transacciones. Index route, login redirects updated; Asistente stays at /asistente. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
import { CopilotChat, useConfigureSuggestions } from "@copilotkit/react-core/v2";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import {
|
||||
CopilotChat,
|
||||
useAgent,
|
||||
useConfigureSuggestions,
|
||||
useCopilotKit,
|
||||
} from "@copilotkit/react-core/v2";
|
||||
import { useCopilotAction } from "@copilotkit/react-core";
|
||||
import { Sparkles } from "lucide-react";
|
||||
import { SpendingSummaryCard, type SpendingSummaryArgs } from "@/components/chat/ChatCards";
|
||||
@@ -16,6 +23,28 @@ const STATIC_SUGGESTIONS = {
|
||||
export default function Asistente() {
|
||||
useConfigureSuggestions(STATIC_SUGGESTIONS);
|
||||
|
||||
// A question typed on the Inicio dashboard arrives via router state:
|
||||
// append it as a user message and run the agent once.
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const { agent } = useAgent();
|
||||
const { copilotkit } = useCopilotKit();
|
||||
const sentRef = useRef(false);
|
||||
useEffect(() => {
|
||||
const ask = (location.state as { ask?: string } | null)?.ask;
|
||||
if (!ask || sentRef.current || !agent) return;
|
||||
sentRef.current = true;
|
||||
// Clear the state so back/refresh doesn't re-send the question.
|
||||
navigate(location.pathname, { replace: true, state: null });
|
||||
agent.addMessage({
|
||||
id: crypto.randomUUID(),
|
||||
role: "user",
|
||||
content: ask,
|
||||
});
|
||||
void copilotkit.runAgent({ agent });
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [agent]);
|
||||
|
||||
useCopilotAction({
|
||||
name: "render_spending_summary",
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user