feat(onboarding): step-agent-waiting polls real agent lastContact via useQuery

This commit is contained in:
Théo LAGACHE
2026-06-18 11:58:18 +02:00
parent 3d1b0aa659
commit 32cf64eebe
2 changed files with 47 additions and 10 deletions
@@ -0,0 +1,16 @@
"use server";
import { userAction } from "@/lib/safe-actions/actions";
import { z } from "zod";
import { getAgentAction } from "@/features/agents/agents.action";
export const getAgentStatusAction = userAction
.schema(z.object({ agentId: z.string() }))
.action(async ({ parsedInput }) => {
const result = await getAgentAction(parsedInput.agentId);
if (!result?.data?.data) return { connected: false };
const agent = result.data.data;
const lastContact = agent.lastContact ? new Date(agent.lastContact) : null;
const connected = lastContact !== null && Date.now() - lastContact.getTime() < 60_000;
return { connected };
});