@woocommerce/data
Version:
WooCommerce Admin data store and utilities
23 lines (22 loc) • 889 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getReviewsError = exports.getReviewsTotalCount = exports.getReviews = void 0;
const getReviews = (state, query) => {
const stringifiedQuery = JSON.stringify(query);
const ids = (state.reviews[stringifiedQuery] &&
state.reviews[stringifiedQuery].data) ||
[];
return ids.map((id) => state.data[id]);
};
exports.getReviews = getReviews;
const getReviewsTotalCount = (state, query) => {
const stringifiedQuery = JSON.stringify(query);
return (state.reviews[stringifiedQuery] &&
state.reviews[stringifiedQuery].totalCount);
};
exports.getReviewsTotalCount = getReviewsTotalCount;
const getReviewsError = (state, query) => {
const stringifiedQuery = JSON.stringify(query);
return state.errors[stringifiedQuery];
};
exports.getReviewsError = getReviewsError;