@infrab4a/connect-angular 5.2.1-beta.2 → 5.2.1-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1644,6 +1644,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1644
1644
  type: Injectable
1645
1645
  }], ctorParameters: function () { return [{ type: CatalogRepositoryService }, { type: CatalogHelpersService }]; } });
1646
1646
 
1647
+ /* eslint-disable no-console */
1647
1648
  class TermSearchStrategy {
1648
1649
  constructor(repositoryService, helpersService) {
1649
1650
  this.repositoryService = repositoryService;
@@ -1720,25 +1721,29 @@ class TermSearchStrategy {
1720
1721
  }
1721
1722
  sortByTermRelevance(params) {
1722
1723
  const { productIds, totalResult, limits, filters, fieldsHelper } = params;
1723
- const defaultGender = filters?.gender?.at(0) || 'male';
1724
+ // const defaultGender = filters?.gender?.at(0) || 'male'
1725
+ console.log('productIds', productIds);
1724
1726
  const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
1727
+ console.log('stockData', stockData);
1725
1728
  const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
1726
- // const productIdsStockGender = productIds.filter((product) =>
1727
- // stockData.some(
1728
- // (result: any) =>
1729
- // result.id === product && (result.gender?.includes(defaultGender) || result.gender?.includes('unisex')),
1730
- // ),
1731
- // )
1729
+ console.log('stockOut', stockOut);
1730
+ // const productIdsStockGender = productIds.filter((product) => stockData.some((result: any) => result.id === product))
1731
+ // && (result.gender?.includes(defaultGender) || result.gender?.includes('unisex'))
1732
1732
  // const productIdsStockNotGender = productIds.filter((product) =>
1733
- // stockData.some(
1734
- // (result: any) =>
1735
- // result.id === product && !result.gender?.includes(defaultGender) && !result.gender?.includes('unisex'),
1736
- // ),
1733
+ // stockData.some((result: any) => result.id === product),
1737
1734
  // )
1735
+ // && !result.gender?.includes(defaultGender) && !result.gender?.includes('unisex')
1738
1736
  // const productIdsStock = productIdsStockGender.concat(productIdsStockNotGender)
1739
- // const productIdsStockOut = productIds.filter((product) => stockOut.some((result: any) => result.id === product))
1740
- const limitedProductId = stockData.concat(stockOut).slice(limits.offset, limits.offset + limits.limit);
1737
+ const productIdsStock = productIds.filter((product) => stockData.some((result) => result.id === product));
1738
+ console.log('productIdsStock', productIdsStock);
1739
+ const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id === product));
1740
+ console.log('productIdsStockOut', productIdsStockOut);
1741
+ const limitedProductId = productIdsStock
1742
+ .concat(productIdsStockOut)
1743
+ .slice(limits.offset, limits.offset + limits.limit);
1744
+ console.log('limitedProductId', limitedProductId);
1741
1745
  const orderedId = productIds.filter((product) => limitedProductId.includes(product));
1746
+ console.log('orderedId', orderedId);
1742
1747
  return this.getDetailedProducts(orderedId, totalResult, fieldsHelper);
1743
1748
  }
1744
1749
  async getDetailedProducts(orderedId, totalResult, fieldsHelper) {
@@ -1750,6 +1755,7 @@ class TermSearchStrategy {
1750
1755
  },
1751
1756
  fields,
1752
1757
  });
1758
+ console.log('detail ordered', orderedId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean));
1753
1759
  return {
1754
1760
  data: orderedId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
1755
1761
  count: totalResult.count,