feat(automation): Add sync functionality to automation rule dialogs

This commit is contained in:
Víctor Falcón 2025-11-14 10:06:05 +01:00
parent 32167b0f80
commit e009abbee1
3 changed files with 10 additions and 4 deletions

View File

@ -27,6 +27,7 @@ import {
isValidRuleStructure,
type RuleStructure,
} from '@/lib/rule-builder-utils';
import { automationRuleSyncService } from '@/services/automation-rule-sync';
import { categorySyncService } from '@/services/category-sync';
import type { Category } from '@/types/category';
import { router } from '@inertiajs/react';
@ -119,7 +120,7 @@ export function CreateAutomationRuleDialog({
action_note_iv: noteIv,
},
{
onSuccess: () => {
onSuccess: async () => {
setOpen(false);
setTitle('');
setPriority('0');
@ -130,6 +131,7 @@ export function CreateAutomationRuleDialog({
setCategoryId('');
setNote('');
setErrors({});
await automationRuleSyncService.sync();
onSuccess?.();
},
onError: (errors) => {

View File

@ -9,6 +9,7 @@ import {
AlertDialogHeader,
AlertDialogTitle,
} from '@/components/ui/alert-dialog';
import { automationRuleSyncService } from '@/services/automation-rule-sync';
import type { AutomationRule } from '@/types/automation-rule';
import { router } from '@inertiajs/react';
import { useState } from 'react';
@ -28,11 +29,12 @@ export function DeleteAutomationRuleDialog({
}: DeleteAutomationRuleDialogProps) {
const [isDeleting, setIsDeleting] = useState(false);
const handleDelete = () => {
const handleDelete = async () => {
setIsDeleting(true);
router.delete(destroy(rule.id).url, {
onSuccess: () => {
onSuccess: async () => {
onOpenChange(false);
await automationRuleSyncService.sync();
onSuccess?.();
},
onFinish: () => {

View File

@ -27,6 +27,7 @@ import {
parseJsonLogic,
type RuleStructure,
} from '@/lib/rule-builder-utils';
import { automationRuleSyncService } from '@/services/automation-rule-sync';
import { categorySyncService } from '@/services/category-sync';
import type { AutomationRule } from '@/types/automation-rule';
import type { Category } from '@/types/category';
@ -157,9 +158,10 @@ export function EditAutomationRuleDialog({
action_note_iv: noteIv,
},
{
onSuccess: () => {
onSuccess: async () => {
onOpenChange(false);
setErrors({});
await automationRuleSyncService.sync();
onSuccess?.();
},
onError: (errors) => {