diff options
| author | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-08-04 23:13:12 -0400 |
|---|---|---|
| committer | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-08-04 23:13:12 -0400 |
| commit | 0f1eb120167c921270a5b1146ba519f477da288c (patch) | |
| tree | 63b8f6eb8efe9ae66b826c721c3e5a9e72ff72ea /src/actions | |
| parent | 4c4f178aa68bc456e50443117e7750647337b1d9 (diff) | |
Removed uneccessary files.
Diffstat (limited to 'src/actions')
| -rw-r--r-- | src/actions/counter.js | 24 | ||||
| -rw-r--r-- | src/actions/shop.js | 79 |
2 files changed, 0 insertions, 103 deletions
diff --git a/src/actions/counter.js b/src/actions/counter.js deleted file mode 100644 index 4ca5254..0000000 --- a/src/actions/counter.js +++ /dev/null @@ -1,24 +0,0 @@ -/** -@license -Copyright (c) 2018 The Polymer Project Authors. All rights reserved. -This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt -The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt -The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt -Code distributed by Google as part of the polymer project is also -subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt -*/ - -export const INCREMENT = 'INCREMENT'; -export const DECREMENT = 'DECREMENT'; - -export const increment = () => { - return { - type: INCREMENT - }; -}; - -export const decrement = () => { - return { - type: DECREMENT - }; -}; diff --git a/src/actions/shop.js b/src/actions/shop.js deleted file mode 100644 index 4542186..0000000 --- a/src/actions/shop.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -@license -Copyright (c) 2018 The Polymer Project Authors. All rights reserved. -This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt -The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt -The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt -Code distributed by Google as part of the polymer project is also -subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt -*/ - -export const GET_PRODUCTS = 'GET_PRODUCTS'; -export const ADD_TO_CART = 'ADD_TO_CART'; -export const REMOVE_FROM_CART = 'REMOVE_FROM_CART'; -export const CHECKOUT_SUCCESS = 'CHECKOUT_SUCCESS'; -export const CHECKOUT_FAILURE = 'CHECKOUT_FAILURE'; - -const PRODUCT_LIST = [ - {"id": 1, "title": "Cabot Creamery Extra Sharp Cheddar Cheese", "price": 10.99, "inventory": 2}, - {"id": 2, "title": "Cowgirl Creamery Mt. Tam Cheese", "price": 29.99, "inventory": 10}, - {"id": 3, "title": "Tillamook Medium Cheddar Cheese", "price": 8.99, "inventory": 5}, - {"id": 4, "title": "Point Reyes Bay Blue Cheese", "price": 24.99, "inventory": 7}, - {"id": 5, "title": "Shepherd's Halloumi Cheese", "price": 11.99, "inventory": 3} -]; - -export const getAllProducts = () => (dispatch, getState) => { - // Here you would normally get the data from the server. We're simulating - // that by dispatching an async action (that you would dispatch when you - // succesfully got the data back) - - // You could reformat the data in the right format as well: - const products = PRODUCT_LIST.reduce((obj, product) => { - obj[product.id] = product - return obj - }, {}); - - dispatch({ - type: GET_PRODUCTS, - products: products - }); -}; - -export const checkout = (productId) => (dispatch) => { - // Here you could do things like credit card validation, etc. - // If that fails, dispatch CHECKOUT_FAILURE. We're simulating that - // by flipping a coin :) - const flip = Math.floor(Math.random() * 2); - if (flip === 0) { - dispatch({ - type: CHECKOUT_FAILURE - }); - } else { - dispatch({ - type: CHECKOUT_SUCCESS - }); - } -}; - -export const addToCart = (productId) => (dispatch, getState) =>{ - const state = getState(); - // Just because the UI thinks you can add this to the cart - // doesn't mean it's in the inventory (user could've fixed it); - if (state.shop.products[productId].inventory > 0) { - dispatch(addToCartUnsafe(productId)); - } -}; - -export const removeFromCart = (productId) => { - return { - type: REMOVE_FROM_CART, - productId - }; -}; - -export const addToCartUnsafe = (productId) => { - return { - type: ADD_TO_CART, - productId - }; -}; |
