From ac0bbe54a03606ef2224bd9f33122c4a15900e24 Mon Sep 17 00:00:00 2001 From: jero Date: Wed, 28 Aug 2019 23:49:34 -0500 Subject: [PATCH] refactor(store): move footer logic into modules --- src/app/components/core/Footer/Footer.js | 2 +- .../{reducers => helpers/createReducer}/createReducer.js | 0 .../createReducer}/createReducer.test.js | 0 src/app/store/helpers/createReducer/index.js | 3 +++ src/app/store/helpers/makeActionCreator/index.js | 3 +++ .../makeActionCreator}/makeActionCreator.js | 0 .../makeActionCreator}/makeActionCreator.test.js | 0 src/app/store/modules/cart/actions/cartAction.js | 2 +- src/app/store/modules/cart/reducers/cart.js | 2 +- .../footerData => modules/footer/actions}/footerData.js | 2 +- .../footer/actions}/footerData.test.js | 0 .../{actions/footerData => modules/footer/actions}/index.js | 0 .../{reducers/footer => modules/footer/reducers}/footer.js | 5 +---- .../footer => modules/footer/reducers}/footer.test.js | 0 src/app/store/modules/footer/reducers/index.js | 3 +++ .../index.js => modules/footer/selectors/getFooter.js} | 6 +----- .../store/{actions => modules/footer/selectors}/index.js | 2 +- src/app/store/modules/products/reducers/products.js | 2 +- src/app/store/reducers/index.js | 2 +- 19 files changed, 18 insertions(+), 16 deletions(-) rename src/app/store/{reducers => helpers/createReducer}/createReducer.js (100%) rename src/app/store/{reducers => helpers/createReducer}/createReducer.test.js (100%) create mode 100644 src/app/store/helpers/createReducer/index.js create mode 100644 src/app/store/helpers/makeActionCreator/index.js rename src/app/store/{actions => helpers/makeActionCreator}/makeActionCreator.js (100%) rename src/app/store/{actions => helpers/makeActionCreator}/makeActionCreator.test.js (100%) rename src/app/store/{actions/footerData => modules/footer/actions}/footerData.js (64%) rename src/app/store/{actions/footerData => modules/footer/actions}/footerData.test.js (100%) rename src/app/store/{actions/footerData => modules/footer/actions}/index.js (100%) rename src/app/store/{reducers/footer => modules/footer/reducers}/footer.js (72%) rename src/app/store/{reducers/footer => modules/footer/reducers}/footer.test.js (100%) create mode 100644 src/app/store/modules/footer/reducers/index.js rename src/app/store/{reducers/footer/index.js => modules/footer/selectors/getFooter.js} (68%) rename src/app/store/{actions => modules/footer/selectors}/index.js (62%) diff --git a/src/app/components/core/Footer/Footer.js b/src/app/components/core/Footer/Footer.js index 390235c4..ae52d73d 100755 --- a/src/app/components/core/Footer/Footer.js +++ b/src/app/components/core/Footer/Footer.js @@ -3,7 +3,7 @@ import React from 'react'; // $FlowIgnore import { useSelector } from 'react-redux'; -import { getFooter } from '@/store/reducers/footer'; +import { getFooter } from '@/store/modules/footer/selectors'; import type { FooterType } from '@/store/types/FooterType'; import Icon from '@/components/base/Icon/Icon'; diff --git a/src/app/store/reducers/createReducer.js b/src/app/store/helpers/createReducer/createReducer.js similarity index 100% rename from src/app/store/reducers/createReducer.js rename to src/app/store/helpers/createReducer/createReducer.js diff --git a/src/app/store/reducers/createReducer.test.js b/src/app/store/helpers/createReducer/createReducer.test.js similarity index 100% rename from src/app/store/reducers/createReducer.test.js rename to src/app/store/helpers/createReducer/createReducer.test.js diff --git a/src/app/store/helpers/createReducer/index.js b/src/app/store/helpers/createReducer/index.js new file mode 100644 index 00000000..6c4a5c71 --- /dev/null +++ b/src/app/store/helpers/createReducer/index.js @@ -0,0 +1,3 @@ +// @flow strict +// eslint-disable-next-line import/prefer-default-export +export { default as createReducer } from './createReducer'; diff --git a/src/app/store/helpers/makeActionCreator/index.js b/src/app/store/helpers/makeActionCreator/index.js new file mode 100644 index 00000000..0e4bc5fd --- /dev/null +++ b/src/app/store/helpers/makeActionCreator/index.js @@ -0,0 +1,3 @@ +// @flow strict +// eslint-disable-next-line import/prefer-default-export +export { default as makeActionCreator } from './makeActionCreator'; diff --git a/src/app/store/actions/makeActionCreator.js b/src/app/store/helpers/makeActionCreator/makeActionCreator.js similarity index 100% rename from src/app/store/actions/makeActionCreator.js rename to src/app/store/helpers/makeActionCreator/makeActionCreator.js diff --git a/src/app/store/actions/makeActionCreator.test.js b/src/app/store/helpers/makeActionCreator/makeActionCreator.test.js similarity index 100% rename from src/app/store/actions/makeActionCreator.test.js rename to src/app/store/helpers/makeActionCreator/makeActionCreator.test.js diff --git a/src/app/store/modules/cart/actions/cartAction.js b/src/app/store/modules/cart/actions/cartAction.js index ecdfd728..16c910ca 100644 --- a/src/app/store/modules/cart/actions/cartAction.js +++ b/src/app/store/modules/cart/actions/cartAction.js @@ -1,6 +1,6 @@ // @flow strict import * as types from '@/store/ActionTypes'; -import makeActionCreator from '@/store/actions/makeActionCreator'; +import { makeActionCreator } from '@/store/helpers/makeActionCreator'; export default makeActionCreator(types.CART_DATA, 'cart'); diff --git a/src/app/store/modules/cart/reducers/cart.js b/src/app/store/modules/cart/reducers/cart.js index 00aea541..6e866043 100644 --- a/src/app/store/modules/cart/reducers/cart.js +++ b/src/app/store/modules/cart/reducers/cart.js @@ -4,7 +4,7 @@ import type { CartType, CartActionType } from '@/store/types/CartType'; import { CART_DATA } from '@/store/ActionTypes'; -import createReducer from '@/store/reducers/createReducer'; +import { createReducer } from '@/store/helpers/createReducer'; const initialState = { quantity: 0, diff --git a/src/app/store/actions/footerData/footerData.js b/src/app/store/modules/footer/actions/footerData.js similarity index 64% rename from src/app/store/actions/footerData/footerData.js rename to src/app/store/modules/footer/actions/footerData.js index 33aee116..71fddd7b 100644 --- a/src/app/store/actions/footerData/footerData.js +++ b/src/app/store/modules/footer/actions/footerData.js @@ -1,6 +1,6 @@ // @flow strict import * as types from '@/store/ActionTypes'; -import makeActionCreator from '@/store/actions/makeActionCreator'; +import { makeActionCreator } from '@/store/helpers/makeActionCreator'; export default makeActionCreator(types.FOOTER_DATA, 'footer'); diff --git a/src/app/store/actions/footerData/footerData.test.js b/src/app/store/modules/footer/actions/footerData.test.js similarity index 100% rename from src/app/store/actions/footerData/footerData.test.js rename to src/app/store/modules/footer/actions/footerData.test.js diff --git a/src/app/store/actions/footerData/index.js b/src/app/store/modules/footer/actions/index.js similarity index 100% rename from src/app/store/actions/footerData/index.js rename to src/app/store/modules/footer/actions/index.js diff --git a/src/app/store/reducers/footer/footer.js b/src/app/store/modules/footer/reducers/footer.js similarity index 72% rename from src/app/store/reducers/footer/footer.js rename to src/app/store/modules/footer/reducers/footer.js index 790202b6..73f849c3 100644 --- a/src/app/store/reducers/footer/footer.js +++ b/src/app/store/modules/footer/reducers/footer.js @@ -3,9 +3,8 @@ import type { FooterType, FooterActionType } from '@/store/types/FooterType'; import { FOOTER_DATA } from '@/store/ActionTypes'; -import type { State } from '@/store/types/State'; -import createReducer from '../createReducer'; +import { createReducer } from '@/store/helpers/createReducer'; const initialState = { social: [ @@ -20,5 +19,3 @@ export default createReducer(initialState, { }; }, }); - -export const getFooter = ({ footer }: State) => footer; diff --git a/src/app/store/reducers/footer/footer.test.js b/src/app/store/modules/footer/reducers/footer.test.js similarity index 100% rename from src/app/store/reducers/footer/footer.test.js rename to src/app/store/modules/footer/reducers/footer.test.js diff --git a/src/app/store/modules/footer/reducers/index.js b/src/app/store/modules/footer/reducers/index.js new file mode 100644 index 00000000..43ad8f8b --- /dev/null +++ b/src/app/store/modules/footer/reducers/index.js @@ -0,0 +1,3 @@ +// @flow strict +// eslint-disable-next-line import/prefer-default-export +export { default as footer } from './footer'; diff --git a/src/app/store/reducers/footer/index.js b/src/app/store/modules/footer/selectors/getFooter.js similarity index 68% rename from src/app/store/reducers/footer/index.js rename to src/app/store/modules/footer/selectors/getFooter.js index dada2c50..d20f5760 100644 --- a/src/app/store/reducers/footer/index.js +++ b/src/app/store/modules/footer/selectors/getFooter.js @@ -1,9 +1,5 @@ // @flow strict import type { State } from '@/store/types/State'; - -import footer from './footer'; - -export default footer; - +// eslint-disable-next-line import/prefer-default-export export const getFooter = (state: State) => state.footer; diff --git a/src/app/store/actions/index.js b/src/app/store/modules/footer/selectors/index.js similarity index 62% rename from src/app/store/actions/index.js rename to src/app/store/modules/footer/selectors/index.js index 87793ac7..c3c80af3 100644 --- a/src/app/store/actions/index.js +++ b/src/app/store/modules/footer/selectors/index.js @@ -1,3 +1,3 @@ // @flow strict // eslint-disable-next-line import/prefer-default-export -export { footerData } from './footerData'; +export { getFooter } from './getFooter'; diff --git a/src/app/store/modules/products/reducers/products.js b/src/app/store/modules/products/reducers/products.js index a540d754..997ed916 100644 --- a/src/app/store/modules/products/reducers/products.js +++ b/src/app/store/modules/products/reducers/products.js @@ -1,7 +1,7 @@ // @flow strict import type { ProductsType, ProductActionType } from '@/store/types/ProductsType'; -import createReducer from '@/store/reducers/createReducer'; +import { createReducer } from '@/store/helpers/createReducer'; import { GET_PRODUCTS_FAILURE, diff --git a/src/app/store/reducers/index.js b/src/app/store/reducers/index.js index 6ee6618a..9bb6be95 100644 --- a/src/app/store/reducers/index.js +++ b/src/app/store/reducers/index.js @@ -4,7 +4,7 @@ import { combineReducers } from 'redux'; import type { Actions } from '@/store/types/Actions'; -import footer from './footer'; +import { footer } from '@/store/modules/footer/reducers'; import { cart } from '@/store/modules/cart/reducers'; import { products } from '@/store/modules/products/reducers';