mirror of
https://github.com/domfelipe/mika-agent-assist.git
synced 2026-08-07 11:56:45 +00:00
Changes
Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
parent
e7085e26ad
commit
87f50bd28f
1 changed files with 18 additions and 6 deletions
|
|
@ -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}>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue