const BasicMachine = Machine({ id: "basicmachine", initial: "inactive", context: {}, states: { copying : { id: "copying", initial: "loading", states: { loading: { invoke: { id: "getscheduledata", src: "loadscheduleservice", onDone: { target: "creating", actions: ["assignScheduleData"] }, onError: { target: "#basicmachine.inactive", actions: "debug" } } }, creating: { invoke: { id: "createschedule", src: "createscheduleservice", onDone: { target: "#basicmachine.inactive", actions: "debug" }, onError: { target: "#basicmachine.inactive", actions: "debug" } } }}, }, inactive: { on: { DUPLICATE: { target: "copying" }, TOGGLE: { target: "active", actions: () => toast.success("go to active") } } }, active: { on: { TOGGLE: { target: "inactive", actions: () => toast.success("go to inactive") } } } } });