finishes functionality for cart, checkout, return and renter registration

This commit is contained in:
David Lick
2020-05-31 23:25:49 -04:00
parent 28e52a4e08
commit 5cd92132b3
326 changed files with 495 additions and 16570 deletions
+16
View File
@@ -73,11 +73,20 @@ export function books(state = initialState, action: Action) {
// ADD_TO_CART action
case actionTypes.ADD_TO_CART:
alert(`Added ${action.data} to the cart`);
return {
...state,
cart: state.cart.concat(action.data)
}
// REMOVE_FROM_CART action
case actionTypes.REMOVE_FROM_CART:
alert(`Removed ${action.data} from the cart`);
return {
...state,
cart: state.cart.filter(item => item !== action.data)
}
// CHECKOUT_BOOK action
case actionTypes.CHECKOUT_BOOK.request:
return {
@@ -115,6 +124,13 @@ export function books(state = initialState, action: Action) {
loading: false,
returnError: action.err
}
// CLEAR_CART action
case actionTypes.CLEAR_CART:
return {
...state,
cart: [],
}
default:
return state;