Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot] 2026-04-25 13:18:43 +00:00
parent e7085e26ad
commit 87f50bd28f

View file

@ -99,16 +99,28 @@ export function TelegramOnboardingWizard({ open, onOpenChange, initialStep }: Pr
onOpenChange(false); onOpenChange(false);
} }
// Após validar token, recarrega agent_instance (já tem bot_username persistido) // Após validar token, recarrega agent_instance, marca onboarding como completo,
function handleValidated(bot: ValidatedBot) { // mostra toast de sucesso e fecha o wizard automaticamente.
async function handleValidated(bot: ValidatedBot) {
setValidated(bot); setValidated(bot);
if (user) { if (user) {
queryClient.invalidateQueries({ queryKey: ["agent-instance", user.id] }); await queryClient.invalidateQueries({ queryKey: ["agent-instance", user.id] });
}
if (agent) {
await supabase
.from("agent_instances")
.update({ telegram_onboarding_completed: true })
.eq("id", agent.id);
if (user) {
await queryClient.invalidateQueries({ queryKey: ["agent-instance", user.id] });
} }
} }
if (typeof window !== "undefined") {
const botUsername = validated?.bot_username ?? agent?.telegram_bot_username ?? ""; window.localStorage.removeItem(STORAGE_KEY);
const connectedAt = agent?.telegram_connected_at ?? null; }
toast.success("Token salvo! Seu agente será ativado em alguns minutos.");
onOpenChange(false);
}
return ( return (
<DialogPrimitive.Root open={open} onOpenChange={onOpenChange}> <DialogPrimitive.Root open={open} onOpenChange={onOpenChange}>