Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot] 2026-05-30 17:57:46 +00:00
parent 9d0e839508
commit 7c541f3459

View file

@ -181,8 +181,17 @@ export function useDeleteCronjob() {
const qc = useQueryClient(); const qc = useQueryClient();
return useMutation({ return useMutation({
mutationFn: async (id: string) => { mutationFn: async (id: string) => {
const { error } = await supabase.from("scheduled_jobs").delete().eq("id", id); const { data, error } = await invokeFunction<{
if (error) throw error; 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: () => { onSuccess: () => {
qc.invalidateQueries({ queryKey: ["cronjobs"] }); qc.invalidateQueries({ queryKey: ["cronjobs"] });