upgrade to node 16, add search by full product id (#84)

This commit is contained in:
Anders Gustafsson
2021-11-02 10:57:11 +01:00
committed by GitHub
parent 043f1455cf
commit 0afe689200
10 changed files with 260 additions and 2892 deletions
+12 -1
View File
@@ -84,7 +84,18 @@ async function getProductsSearchResult(
const prods = Promise.all([
prodApi.searchByName(q),
prodApi.searchByArtNo(q),
]).then((d) => d.flat());
prodApi.searchByCompleteProductId(q),
]).then((d) => {
// flatten, remove falsy (each searchBy... can return undefined above)
// and finally remove duplicates.
const products = {} as { [key: string]: Product };
d.flat().forEach((product) => {
if (product && !products[product.id]) {
products[product.id] = product;
}
});
return Object.values(products);
});
return {
q: q,