-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
88 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// @flow strict | ||
import * as types from '@/store/ActionTypes'; | ||
|
||
import makeActionCreator from '@/store/actions/makeActionCreator'; | ||
|
||
export default makeActionCreator(types.CART_DATA, 'cart'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// @flow strict | ||
|
||
import cartAction from './cartAction'; | ||
|
||
describe('cartAction action', () => { | ||
it('should return the quantity', () => { | ||
const quantity = 0; | ||
const expectedData = { type: 'CART_DATA', cart: { quantity } }; | ||
expect(cartAction({ quantity })).toEqual(expectedData); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// @flow strict | ||
// eslint-disable-next-line import/prefer-default-export | ||
export { default as cartAction } from './cartAction'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// @flow strict | ||
|
||
import type { CartType, CartActionType } from '@/store/types/CartType'; | ||
|
||
import { CART_DATA } from '@/store/ActionTypes'; | ||
|
||
import createReducer from '../createReducer'; | ||
|
||
const initialState = { | ||
quantity: 0, | ||
}; | ||
|
||
export default createReducer<CartType, CartActionType>(initialState, { | ||
[CART_DATA](state) { | ||
return { | ||
...state, | ||
}; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// @flow strict | ||
import cart from './cart'; | ||
|
||
describe('cart reducer', () => { | ||
const expectedState = { | ||
quantity: 0, | ||
}; | ||
|
||
it('should return initial state', () => { | ||
const initialState = cart(undefined, { type: '', quantity: 0 }); | ||
|
||
expect(initialState).toStrictEqual(expectedState); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// @flow strict | ||
|
||
import type { State } from '@/store/types/State'; | ||
|
||
import cart from './cart'; | ||
|
||
export default cart; | ||
|
||
export const cartFooter = (state: State) => state.cart; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// @flow strict | ||
import type { Action } from 'redux'; | ||
|
||
export type CartType = { | ||
quantity: number | ||
}; | ||
|
||
export type CartActionType = { | ||
...$Exact<Action<string>>, | ||
...$Exact<CartType> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
// @flow strict | ||
|
||
import type { ProductsType } from '@/store/types/ProductsType'; | ||
import type { CartType } from '@/store/types/CartType'; | ||
import type { FooterType } from '@/store/types/FooterType'; | ||
import type { ProductsType } from '@/store/types/ProductsType'; | ||
|
||
export type State = { | ||
cart: CartType, | ||
footer: FooterType, | ||
products: ProductsType, | ||
footer: FooterType | ||
}; |