diff --git a/src/app/store/config/middlewares/apiMiddleware/apiMiddleware.js b/src/app/store/config/middlewares/apiMiddleware/apiMiddleware.js index 62d0fb79..41f0395f 100644 --- a/src/app/store/config/middlewares/apiMiddleware/apiMiddleware.js +++ b/src/app/store/config/middlewares/apiMiddleware/apiMiddleware.js @@ -3,9 +3,9 @@ import type { Dispatch, Middleware } from 'redux'; import type { State } from '@/store/types/State'; -import type { Actions, MiddlewareAction } from '@/store/types/Actions'; +import type { Actions, AsyncAction } from '@/store/types/Actions'; -type ApiMiddlewareType = Middleware>>; +type ApiMiddlewareType = Middleware>; const apiMiddleware: ApiMiddlewareType = ({ dispatch, getState }) => (next) => (action) => { const { diff --git a/src/app/store/modules/products/actions/fetchProducts.js b/src/app/store/modules/products/actions/fetchProducts.js index 9d8971aa..952cf9ef 100644 --- a/src/app/store/modules/products/actions/fetchProducts.js +++ b/src/app/store/modules/products/actions/fetchProducts.js @@ -4,13 +4,13 @@ import { api } from '@/api'; import { ASYNC_ACTION_TYPE } from '@/constants'; import * as types from '@/store/ActionTypes'; -import type { State } from '@/store/types/State'; +// import type { State } from '@/store/types/State'; import type { AsyncAction } from '@/store/types/Actions'; import type { ProductsType } from '@/store/types/ProductsType'; import { getProducts } from '@/store/modules/products/selectors'; -export default function fetchProducts(query: string = ''): AsyncAction { +export default function fetchProducts(query: string = ''): AsyncAction { return { type: ASYNC_ACTION_TYPE, types: [ @@ -19,7 +19,7 @@ export default function fetchProducts(query: string = ''): AsyncAction { types.GET_PRODUCTS_FAILURE, ], callAPI: () => api.get(query), - shouldCallAPI: (state: State) => { + shouldCallAPI: (state) => { const products = getProducts(state); // $FlowFixMe - это не должно орать return !products.length; diff --git a/src/app/store/types/Actions.js b/src/app/store/types/Actions.js index 6596bdc3..4ee7d167 100644 --- a/src/app/store/types/Actions.js +++ b/src/app/store/types/Actions.js @@ -1,22 +1,19 @@ // @flow strict -import type { FooterActionType } from '@/store/types/FooterType'; import type { CartActionType } from '@/store/types/CartType'; +import type { FooterActionType } from '@/store/types/FooterType'; import type { ProductActionType } from '@/store/types/ProductsType'; +import type { State } from '@/store/types/State'; export type Actions = CartActionType | FooterActionType | ProductActionType; -export type AsyncAction = { +export type AsyncAction = { + type: string, types?: Array, callAPI?: () => Promise<*>, - shouldCallAPI?: (S) => boolean, + shouldCallAPI?: (State) => boolean, payload?: *, }; - -export type MiddlewareAction = { - type: string, - ...$Exact> -};