-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7af4c75
commit 55a5779
Showing
12 changed files
with
544 additions
and
56 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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,34 @@ | ||
import {IProduct} from "../../types/IProduct"; | ||
import {enumBasketItems} from '../../types/enumBasketItems' | ||
|
||
interface IActionBasket { | ||
type: string, | ||
payload: IProduct | ||
|
||
} | ||
|
||
interface IStateBasket{ | ||
basketSneakers: IProduct[] | ||
} | ||
|
||
|
||
const initialState: IStateBasket = { | ||
basketSneakers: [] | ||
} | ||
|
||
|
||
|
||
export const basketReducer = (state = initialState, action: IActionBasket) => { | ||
switch (action.type){ | ||
case enumBasketItems.ADD_ITEM: | ||
return {...state, basketSneakers: [...state.basketSneakers, action.payload]} | ||
default: return state | ||
} | ||
} | ||
|
||
|
||
|
||
export const addToBasket = (sneaker: IProduct) :IActionBasket => ({ | ||
type: enumBasketItems.ADD_ITEM, | ||
payload: sneaker | ||
}) |
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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import {combineReducers} from "redux"; | ||
import {fetchProductsReducer} from "./fetchProductsReducer"; | ||
import {basketReducer} from "./basketReducer"; | ||
|
||
|
||
export const rootReducer = combineReducers({ | ||
products: fetchProductsReducer | ||
items: fetchProductsReducer, | ||
basketItems: basketReducer | ||
} | ||
) |
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,7 @@ | ||
export interface IProduct{ | ||
title: string | ||
subTitle: string, | ||
price: string | ||
src: string | ||
id: number | ||
} |
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,4 @@ | ||
export enum enumBasketItems { | ||
ADD_ITEM = 'ADD_ITEM', | ||
DELETE_ITEM = 'DELETE_ITEM' | ||
} |