From 7c541f3459472cf35ff58ea49d795dd07c293c6a Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 30 May 2026 17:57:46 +0000 Subject: [PATCH] Changes Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com> --- src/hooks/use-cronjobs.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/hooks/use-cronjobs.ts b/src/hooks/use-cronjobs.ts index 90c4a08..87652a0 100644 --- a/src/hooks/use-cronjobs.ts +++ b/src/hooks/use-cronjobs.ts @@ -181,8 +181,17 @@ export function useDeleteCronjob() { const qc = useQueryClient(); return useMutation({ mutationFn: async (id: string) => { - const { error } = await supabase.from("scheduled_jobs").delete().eq("id", id); - if (error) throw error; + const { data, error } = await invokeFunction<{ + success: boolean; + job_id: string; + agent_instance_id: string; + archived: boolean; + deleted: boolean; + runtime_sync_warning: string | null; + }>("delete-cronjob", { job_id: id }); + if (error) throw new Error(error.message); + if (!data?.success) throw new Error("Erro ao excluir automação."); + return data; }, onSuccess: () => { qc.invalidateQueries({ queryKey: ["cronjobs"] });