diff --git a/mailpoet/assets/js/src/automation/api.tsx b/mailpoet/assets/js/src/automation/api/hooks.ts similarity index 98% rename from mailpoet/assets/js/src/automation/api.tsx rename to mailpoet/assets/js/src/automation/api/hooks.ts index 103ed43aae..b203c6e198 100644 --- a/mailpoet/assets/js/src/automation/api.tsx +++ b/mailpoet/assets/js/src/automation/api/hooks.ts @@ -1,5 +1,5 @@ import { useCallback, useEffect, useState } from 'react'; -import { api } from './config'; +import { api } from '../config'; const API_URL = `${api.root}/mailpoet/v1/automation`; diff --git a/mailpoet/assets/js/src/automation/editor/store/api.ts b/mailpoet/assets/js/src/automation/api/index.ts similarity index 81% rename from mailpoet/assets/js/src/automation/editor/store/api.ts rename to mailpoet/assets/js/src/automation/api/index.ts index 30620c04e5..37e5b8f5aa 100644 --- a/mailpoet/assets/js/src/automation/editor/store/api.ts +++ b/mailpoet/assets/js/src/automation/api/index.ts @@ -1,5 +1,7 @@ import apiFetch from '@wordpress/api-fetch'; -import { api } from '../../config'; +import { api } from '../config'; + +export * from './hooks'; const apiUrl = `${api.root}/mailpoet/v1/automation/`; diff --git a/mailpoet/assets/js/src/automation/editor/index.tsx b/mailpoet/assets/js/src/automation/editor/index.tsx index 2d7ac1c993..94b1695c43 100644 --- a/mailpoet/assets/js/src/automation/editor/index.tsx +++ b/mailpoet/assets/js/src/automation/editor/index.tsx @@ -15,6 +15,7 @@ import { KeyboardShortcuts } from './components/keyboard-shortcuts'; import { Sidebar } from './components/sidebar'; import { Workflow } from './components/workflow'; import { store, storeName } from './store'; +import { initializeApi } from '../api'; // See: // https://github.com/WordPress/gutenberg/blob/9601a33e30ba41bac98579c8d822af63dd961488/packages/edit-post/src/components/layout/index.js @@ -75,6 +76,7 @@ function Editor(): JSX.Element { window.addEventListener('DOMContentLoaded', () => { const root = document.getElementById('mailpoet_automation_editor'); if (root) { + initializeApi(); ReactDOM.render(, root); } }); diff --git a/mailpoet/assets/js/src/automation/editor/store/index.ts b/mailpoet/assets/js/src/automation/editor/store/index.ts index 403ca10b5a..17d2596d3d 100644 --- a/mailpoet/assets/js/src/automation/editor/store/index.ts +++ b/mailpoet/assets/js/src/automation/editor/store/index.ts @@ -1,7 +1,6 @@ import { createReduxStore, register, StoreDescriptor } from '@wordpress/data'; import { controls } from '@wordpress/data-controls'; import * as actions from './actions'; -import { initializeApi } from './api'; import { storeName } from './constants'; import { initialState } from './initial_state'; import { reducer } from './reducer'; @@ -15,8 +14,6 @@ type StoreType = Omit & { name: typeof storeName; }; -initializeApi(); - export const store = createReduxStore(storeName, { // eslint-disable-next-line @typescript-eslint/no-explicit-any -- the "Action" type is missing thunks with "dispatch" actions: actions as any,