diff --git a/src/app/store/reducers/products.js b/src/app/store/reducers/products.js index f97cd674..f7a4cda1 100644 --- a/src/app/store/reducers/products.js +++ b/src/app/store/reducers/products.js @@ -1,10 +1,21 @@ // @flow strict +import type { Action } from 'redux'; + +import type { Response } from '@/store/types/CommonType'; +import type { ProductType } from '@/store/types/ProductsType'; import createReducer from './createReducer'; import { GET_PRODUCTS_SUCCESS } from '../ActionTypes'; -export default createReducer([], { +type ProductsType = Array; + +type ProductActionType = { + ...$Exact>, + ...$Exact> +}; + +export default createReducer([], { [GET_PRODUCTS_SUCCESS](state, action) { const { response: { @@ -13,4 +24,4 @@ export default createReducer([], { } = action; return [...data]; } -}); \ No newline at end of file +}); diff --git a/src/app/store/types/CommonType.js b/src/app/store/types/CommonType.js new file mode 100644 index 00000000..9c05de23 --- /dev/null +++ b/src/app/store/types/CommonType.js @@ -0,0 +1,7 @@ +// @flow strict + +export type Response = { + response: { + data: D + } +}; diff --git a/src/app/store/types/ProductsType.js b/src/app/store/types/ProductsType.js new file mode 100644 index 00000000..e693b023 --- /dev/null +++ b/src/app/store/types/ProductsType.js @@ -0,0 +1,12 @@ +// @flow strict + +export type ProductType = { + _id: string, + name: string, + image: string, + imageHovered: string, + description: string, + price: number, + stock: number, + shop: string, +};