Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot] 2026-04-17 18:53:49 +00:00
parent 124f70528b
commit a32c05a679
10 changed files with 721 additions and 0 deletions

View file

@ -0,0 +1,30 @@
"use client";
import { useQuery } from "@tanstack/react-query";
import { supabase } from "@/integrations/supabase/client";
import { useAuth } from "@/hooks/use-auth";
export interface AgentInstance {
id: string;
user_id: string;
status: string;
telegram_bot_username: string | null;
created_at: string;
}
export function useAgentInstance() {
const { user } = useAuth();
return useQuery({
queryKey: ["agent-instance", user?.id],
enabled: !!user,
queryFn: async (): Promise<AgentInstance | null> => {
const { data, error } = await supabase
.from("agent_instances")
.select("id, user_id, status, telegram_bot_username, created_at")
.eq("user_id", user!.id)
.maybeSingle();
if (error) throw error;
return data;
},
});
}