From 9c83ac026b2e719a48b17325e8aca2d71dfc8ea7 Mon Sep 17 00:00:00 2001 From: jero Date: Mon, 23 Sep 2019 08:33:24 +0300 Subject: [PATCH] refactor(products): remove payload is only for actions --- src/app/pages/Home/Home.js | 4 ++-- .../store/modules/products/reducers/products.js | 4 ++-- src/app/store/types/ProductsType.js | 15 ++++++++------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/app/pages/Home/Home.js b/src/app/pages/Home/Home.js index 39031d21..aeb43bbe 100644 --- a/src/app/pages/Home/Home.js +++ b/src/app/pages/Home/Home.js @@ -14,7 +14,7 @@ import './Home.scss'; const Home = () => { const dispatch = useDispatch(); - const { isLoading, payload, error }: ProductsType = useSelector(getProducts); + const { isLoading, products, error }: ProductsType = useSelector(getProducts); useEffect(() => { dispatch(fetchProducts(`/products`)); @@ -26,7 +26,7 @@ const Home = () => {
{ error ? ({ error.message }) : null} { isLoading ? () : null} - { !isLoading ? payload.map((product) => ( + { !isLoading ? products.map((product) => (
(initialState, { @@ -31,7 +31,7 @@ export default createReducer(initialState, { return { ...state, isLoading: false, - payload: [...data], + products: [...data], }; }, [GET_PRODUCTS_FAILURE](state, action) { diff --git a/src/app/store/types/ProductsType.js b/src/app/store/types/ProductsType.js index 47abf6db..a16fd526 100644 --- a/src/app/store/types/ProductsType.js +++ b/src/app/store/types/ProductsType.js @@ -1,7 +1,7 @@ // @flow strict import type { Action } from 'redux'; -import type { Response, ResponseError, Base } from '@/store/types/CommonType'; +import type { Response, ResponseError } from '@/store/types/CommonType'; export type ProductType = { _id: string, @@ -14,12 +14,13 @@ export type ProductType = { shop: string, }; -export type ProductsType = Base>; -// export type ProductsType = { -// isLoading: boolean, -// payload: Array, -// ...$Exact, -// }; +export type ProductsType = { + isLoading: boolean, + products: Array, + error: ?{ + message: string + }, +}; export type ProductActionType = { ...$Exact>,