orderiom-api-package 0.4.80 → 0.4.82

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orderiom-api-package",
3
- "version": "0.4.80",
3
+ "version": "0.4.82",
4
4
  "description": "This package will install all necessary API calls for every orderiom restaurant",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -356,6 +356,8 @@ const actions = {
356
356
  }
357
357
  }).then(res => {
358
358
  res.data.data.forEach(productInCategory => {
359
+ productInCategory.happyHours = [];
360
+
359
361
  let quantity = 0;
360
362
  state.ShoppingCart
361
363
  .filter(itemInCart => Number(itemInCart.RestaurantProductId) === Number(productInCategory.id))
@@ -396,6 +398,8 @@ const actions = {
396
398
  }
397
399
  if (res.data.data.length) {
398
400
  res.data.data.forEach(productInCategory => {
401
+ productInCategory.happyHours = [];
402
+
399
403
  let quantity = 0;
400
404
  state.ShoppingCart
401
405
  .filter(itemInCart => Number(itemInCart.RestaurantProductId) === Number(productInCategory.id))
@@ -448,18 +452,24 @@ const actions = {
448
452
  const data = res.data.data || [];
449
453
  if(!Array.isArray(data)) return {...res, data: []};
450
454
 
451
- data.forEach(({happyHour, id: productId}) => {
452
- if(!happyHour?.length) return;
453
- const product = state.products.find(product => product.id === productId);
455
+ const productList = state.showPinnedProducts ? state.pinnedProducts : state.products;
456
+ if(!productList || !productList.length){
457
+ console.error(`getProductsHappyHourTime: product list is empty`);
458
+ return;
459
+ }
460
+
461
+ data.forEach(({happyHour: happyHours, id: productId}) => {
462
+ if(!happyHours || !happyHours.length) return;
463
+ const product = productList.find(product => product.id === productId);
454
464
  if(!product) {
455
- console.log(`Could not assign happyHour:${happyHour.id} to product:${productId}`);
465
+ console.error(`getProductsHappyHourTime: Could not assign happyHours to product:${productId}`);
456
466
  return;
457
467
  }
458
- product.happyHour = {
459
- weekday_id: happyHour.weekday_id,
460
- start_date: happyHour.start_date,
461
- end_date: happyHour.end_date,
462
- }
468
+ product.happyHours = happyHours.map(happyHourItem => ({
469
+ weekday_id: happyHourItem.weekday_id,
470
+ start_date: happyHourItem.start_date,
471
+ end_date: happyHourItem.end_date,
472
+ }))
463
473
  })
464
474
 
465
475
  return {...res, data};