Skip to content

Instantly share code, notes, and snippets.

@grabbou
Last active September 17, 2015 08:25
Show Gist options
  • Save grabbou/6c1df01739b599edda5a to your computer and use it in GitHub Desktop.
Save grabbou/6c1df01739b599edda5a to your computer and use it in GitHub Desktop.
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