2021-02-23 14:30:52 +00:00
|
|
|
import ProductDetails from "../../apiRequests/storeFront/ProductDetails";
|
|
|
|
import Search from "../../apiRequests/storeFront/Search";
|
2021-02-12 14:36:13 +00:00
|
|
|
|
2021-02-25 10:40:07 +00:00
|
|
|
export const isProductVisible = (productId, channelSlug, name) => {
|
|
|
|
const productDetails = new ProductDetails();
|
|
|
|
return productDetails
|
|
|
|
.getProductDetails(productId, channelSlug)
|
|
|
|
.then(productDetailsResp => {
|
|
|
|
const product = productDetailsResp.body.data.product;
|
|
|
|
return product !== null && product.name === name;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const isProductAvailableForPurchase = (productId, channelSlug) => {
|
|
|
|
const productDetails = new ProductDetails();
|
|
|
|
return productDetails
|
|
|
|
.getProductDetails(productId, channelSlug)
|
|
|
|
.then(
|
|
|
|
productDetailsResp =>
|
|
|
|
productDetailsResp.body.data.product.isAvailableForPurchase
|
|
|
|
);
|
|
|
|
};
|
|
|
|
export const isProductVisibleInSearchResult = (productName, channelSlug) => {
|
|
|
|
const search = new Search();
|
|
|
|
return search
|
|
|
|
.searchInShop(productName, channelSlug)
|
|
|
|
.then(
|
|
|
|
resp =>
|
|
|
|
resp.body.data.products.totalCount !== 0 &&
|
|
|
|
resp.body.data.products.edges[0].node.name === productName
|
|
|
|
);
|
|
|
|
};
|