diff --git a/.gitignore b/.gitignore index 80ea656..fd5cab5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Logs -logs +/logs *.log npm-debug.log* yarn-debug.log* diff --git a/src/admin/store/logs/index.js b/src/admin/store/logs/index.js new file mode 100644 index 0000000..81d6228 --- /dev/null +++ b/src/admin/store/logs/index.js @@ -0,0 +1,17 @@ +/** + * Internal dependencies + */ +import reducer from './reducer'; +import * as selectors from './selectors'; + +/** + * WordPress dependencies + */ +import { createReduxStore, register } from '@wordpress/data'; + +const store = createReduxStore('redirect-txt/logs', { + reducer, + selectors, +}); + +register(store); diff --git a/src/admin/store/logs/reducer.js b/src/admin/store/logs/reducer.js new file mode 100644 index 0000000..00a8680 --- /dev/null +++ b/src/admin/store/logs/reducer.js @@ -0,0 +1,7 @@ +const { logs } = window.redirectTxtAdminData; + +function reducer(state = { logs }) { + return state; +} + +export default reducer; diff --git a/src/admin/store/logs/selectors.js b/src/admin/store/logs/selectors.js new file mode 100644 index 0000000..7cd85b5 --- /dev/null +++ b/src/admin/store/logs/selectors.js @@ -0,0 +1,3 @@ +export function getLogs(state) { + return state?.logs || ''; +}