dagflow triggers
This commit is contained in:
1 parent
5dcd17ad17
commit
468a022582
12 files changed
+691
-3
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import { AutomationData } from "types/automations";
|
||||
import { AutomationTrigger } from '../types/automations/triggers';
|
||||
|
||||
export type AumationStateEditor = ReturnType<typeof makeAumationStateEditor>;
|
||||
export type AutomationStateTriggerEditor = AumationStateEditor['triggers'];
|
||||
|
||||
export const makeAumationStateEditor = (
|
||||
automation: AutomationData,
|
||||
onUpdate: (a: AutomationData) => void,
|
||||
) => ({
|
||||
onUpdate,
|
||||
triggers: {
|
||||
update: (i: number, t: AutomationTrigger) => onUpdate({
|
||||
...automation,
|
||||
trigger: automation.trigger
|
||||
.slice(0, i)
|
||||
.concat([t])
|
||||
.concat(
|
||||
automation.trigger.slice(i + 1)
|
||||
)
|
||||
}),
|
||||
delete: (i: number) => onUpdate({
|
||||
...automation,
|
||||
trigger: automation.trigger
|
||||
.slice(0, i)
|
||||
.concat(
|
||||
automation.trigger.slice(i + 1)
|
||||
)
|
||||
}),
|
||||
add: (t: AutomationTrigger) => onUpdate({
|
||||
...automation,
|
||||
trigger: automation.trigger
|
||||
.concat([t])
|
||||
}),
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user