-
-
Save grabbou/6c1df01739b599edda5a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export const currentCustomer = ({router, order, customer}) => { | |
const customerId = router.params.customerId; // zależy jak masz w <Route path="/customers/:customerId" /> | |
const currentCustomer = customer.list | |
? customer.list.find(customer => customer._id === customerId) | |
: null; | |
const currentCustomerOrders = order.list | |
? order.list.filter(order => order.user._id === customerId) | |
: null; | |
return { | |
currentCustomer: currentCustomer, | |
currentCustomerId: customerId, | |
currentCustomerOrders: currentCustomerOrders, | |
isCustomerLoading: order.isListLoading || customer.isListLoading | |
}; | |
}; | |
export const currentProduct = ({router, product}) => { | |
const productId = router.params.productId; // zależy jak masz w <Route path="/products/:productId" /> | |
const currentProduct = customer.list | |
? product.list.find(product => product._id === productId) | |
: null; | |
return { | |
currentProduct, | |
currentProductId: productId, | |
isProductLoading: product.isListLoading | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment