Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
subscribe(reviewsRouteDidEnter$, ({ dispatch, getState }) => {
const currentCount = getCurrentReviewCount(getState());
if (currentCount >= REVIEW_ITEMS_PER_PAGE) {
// No need to fetch.
return;
}
dispatch(fetchReviews(getCurrentBaseProductId(getState()), REVIEW_ITEMS_PER_PAGE));
});
}
subscribe(reviewsRouteDidEnter$, ({ dispatch, getState }) => {
const state = getState();
const productId = getCurrentBaseProductId(state);
if (!state.user.login.isLoggedIn) {
return;
}
// Only dispatch when review is not yet in store
dispatch(getUserReview(productId));
});
subscribe(routeDidEnter(ITEM_PATH), ({ dispatch, getState }) => {
const productId = getCurrentBaseProductId(getState());
dispatch(getProduct(productId));
});
subscribe(shouldFetchReviews$, ({ dispatch, getState }) => {
const baseProductId = getCurrentBaseProductId(getState());
if (baseProductId) {
dispatch(getProductReviews(baseProductId, REVIEW_PREVIEW_COUNT));
}
});
}
(dispatch, getState) => {
const state = getState();
const currentProductId = getCurrentBaseProductId(state);
const productId = selectedVariantId || currentProductId;
if (!productId) {
return;
}
dispatch(requestProductData(productId, selectedVariantId));
dispatch(getProduct(productId));
};
const mapStateToProps = (state, props) => ({
currentReviewCount: getCurrentReviewCount(state, props),
isFetching: getReviewsFetchingState(state, props),
productId: getCurrentBaseProductId(state, props),
totalReviewCount: getReviewsTotalCount(state, props),
});
const mapStateToProps = state => ({
currentReviewCount: getCurrentReviewCount(state),
isFetching: getReviewsFetchingState(state),
productId: getCurrentBaseProductId(state),
totalReviewCount: getReviewsTotalCount(state),
});
const mapStateToProps = state => ({
authorName: getDefaultAuthorName(state),
productId: getCurrentBaseProductId(state),
review: getUserReviewForProduct(state),
isLoadingUserReview: getUserReviewFirstFetchState(state),
});
const mapStateToProps = (state, props) => ({
currentReviewCount: getCurrentReviewCount(state, props),
isFetching: getReviewsFetchingState(state, props),
productId: getCurrentBaseProductId(state, props),
totalReviewCount: getReviewsTotalCount(state, props),
});
const mapStateToProps = state => ({
variants: getProductVariants(state),
currentBaseProductId: getCurrentBaseProductId(state),
currentProductVariantId: getCurrentProductVariantId(state),
getVariantsByProductId: productId => getVariantsByProductId(state, null, productId),
});