Move api setup to automation root, fix initialization side-effect
[MAILPOET-4420]
This commit is contained in:
@ -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`;
|
||||
|
@ -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/`;
|
||||
|
@ -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(<Editor />, root);
|
||||
}
|
||||
});
|
||||
|
@ -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<StoreDescriptor, 'name'> & {
|
||||
name: typeof storeName;
|
||||
};
|
||||
|
||||
initializeApi();
|
||||
|
||||
export const store = createReduxStore<State>(storeName, {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- the "Action" type is missing thunks with "dispatch"
|
||||
actions: actions as any,
|
||||
|
Reference in New Issue
Block a user