|
1 | 1 | import { combineReducers } from 'redux' |
2 | | -import { default as cart, getQuantity, getAddedIds } from './cart' |
3 | | -import { default as products, getProduct } from './products' |
| 2 | +import cart, * as fromCart from './cart' |
| 3 | +import products, * as fromProducts from './products' |
4 | 4 |
|
5 | 5 | export function getTotal(state) { |
6 | | - return getAddedIds(state.cart).reduce((total, id) => |
7 | | - total + getProduct(state.products, id).price * getQuantity(state.cart, id), |
| 6 | + return fromCart.getAddedIds(state.cart).reduce((total, id) => |
| 7 | + total + ( |
| 8 | + fromProducts.getProduct(state.products, id).price * |
| 9 | + fromCart.getQuantity(state.cart, id) |
| 10 | + ), |
8 | 11 | 0 |
9 | 12 | ).toFixed(2) |
10 | 13 | } |
11 | 14 |
|
12 | 15 | export function getCartProducts(state) { |
13 | | - return getAddedIds(state.cart).map(id => Object.assign( |
| 16 | + return fromCart.getAddedIds(state.cart).map(id => Object.assign( |
14 | 17 | {}, |
15 | | - getProduct(state.products, id), |
| 18 | + fromProducts.getProduct(state.products, id), |
16 | 19 | { |
17 | | - quantity: getQuantity(state.cart, id) |
| 20 | + quantity: fromCart.getQuantity(state.cart, id) |
18 | 21 | } |
19 | 22 | )) |
20 | 23 | } |
|
0 commit comments