@infrab4a/connect-angular 5.2.1-beta.3 → 5.2.1-beta.5
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.
- package/esm2020/services/catalog/strategies/term-search.strategy.mjs +16 -5
- package/fesm2015/infrab4a-connect-angular.mjs +14 -5
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +15 -4
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -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,22 +1721,31 @@ 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
|
-
|
|
1729
|
+
console.log('stockOut', stockOut);
|
|
1730
|
+
// const productIdsStockGender = productIds.filter((product) => stockData.some((result: any) => result.id === product))
|
|
1727
1731
|
// && (result.gender?.includes(defaultGender) || result.gender?.includes('unisex'))
|
|
1728
1732
|
// const productIdsStockNotGender = productIds.filter((product) =>
|
|
1729
1733
|
// stockData.some((result: any) => result.id === product),
|
|
1730
1734
|
// )
|
|
1731
1735
|
// && !result.gender?.includes(defaultGender) && !result.gender?.includes('unisex')
|
|
1732
1736
|
// const productIdsStock = productIdsStockGender.concat(productIdsStockNotGender)
|
|
1733
|
-
const productIdsStock =
|
|
1737
|
+
const productIdsStock = productIds.filter((product) => stockData.some((result) => result.id === product));
|
|
1738
|
+
console.log('productIdsStock', productIdsStock);
|
|
1734
1739
|
const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id === product));
|
|
1740
|
+
console.log('productIdsStockOut', productIdsStockOut);
|
|
1741
|
+
console.log('concat', productIdsStock.concat(productIdsStockOut));
|
|
1735
1742
|
const limitedProductId = productIdsStock
|
|
1736
1743
|
.concat(productIdsStockOut)
|
|
1737
1744
|
.slice(limits.offset, limits.offset + limits.limit);
|
|
1738
|
-
|
|
1745
|
+
console.log('limitedProductId', limitedProductId);
|
|
1746
|
+
// const orderedId = productIds.filter((product) => limitedProductId.includes(product))
|
|
1747
|
+
const orderedId = productIds.filter((product) => limitedProductId.some((p) => p === product));
|
|
1748
|
+
console.log('orderedId', orderedId);
|
|
1739
1749
|
return this.getDetailedProducts(orderedId, totalResult, fieldsHelper);
|
|
1740
1750
|
}
|
|
1741
1751
|
async getDetailedProducts(orderedId, totalResult, fieldsHelper) {
|
|
@@ -1747,6 +1757,7 @@ class TermSearchStrategy {
|
|
|
1747
1757
|
},
|
|
1748
1758
|
fields,
|
|
1749
1759
|
});
|
|
1760
|
+
console.log('detail ordered', orderedId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean));
|
|
1750
1761
|
return {
|
|
1751
1762
|
data: orderedId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
|
|
1752
1763
|
count: totalResult.count,
|