Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot] 2026-05-28 12:46:33 +00:00
parent 6c0ccff305
commit c6b67e98b8
9 changed files with 1033 additions and 141 deletions

View file

@ -142,16 +142,29 @@ export function useCreateCronjob() {
});
}
export async function markCronjobRuntimeSyncError(id: string, detail: string) {
const message = detail.slice(0, 2000);
const { error } = await supabase
.from("scheduled_jobs")
.update({
status: "error",
auto_paused_reason: "Falha ao sincronizar esta automação com o runtime do agente.",
runtime_state: "error",
runtime_last_status: "error",
runtime_last_error: message,
})
.eq("id", id);
if (error) throw error;
}
export function useUpdateCronjobStatus() {
const qc = useQueryClient();
return useMutation({
mutationFn: async ({ id, status }: { id: string; status: "active" | "paused" }) => {
const update: { status: "active" | "paused"; auto_paused_reason?: null } = { status };
if (status === "paused") update.auto_paused_reason = null;
const { error } = await supabase
.from("scheduled_jobs")
.update(update)
.eq("id", id);
const { error } = await supabase.from("scheduled_jobs").update(update).eq("id", id);
if (error) throw error;
},
onSuccess: () => {