orderiom-api-package 0.4.23 → 0.4.25

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.23",
3
+ "version": "0.4.25",
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",
@@ -102,6 +102,12 @@ const getters = {
102
102
  });
103
103
  return result;
104
104
  },
105
+ hasDelay(state, getters, rootState){
106
+ const dt = deliveryCodeToName(state.basketInfo.deliveryType);
107
+ if(!dt) return false;
108
+ const closedToday = rootState.orderiomApiPackage.restaurant.restaurantInfo.closed || false;
109
+ return Boolean(closedToday || rootState.orderiomApiPackage.restaurant.restaurantInfo[`${dt}_hours`]);
110
+ },
105
111
  minDateTimeForDelivery (state, getters, rootState){
106
112
  const dt = deliveryCodeToName(state.basketInfo.deliveryType)
107
113
  if(!dt) return null;
@@ -237,7 +243,7 @@ const mutations = {
237
243
  }
238
244
  };
239
245
  const actions = {
240
- getCategories({ commit, dispatch, rootState }, restaurantId) {
246
+ getCategories({ commit, dispatch, rootState, state }, restaurantId) {
241
247
  let basketId = undefined;
242
248
  try {
243
249
  basketId = calculateBasketIdParameter(
@@ -258,7 +264,17 @@ const actions = {
258
264
  if (res.data.data.length) {
259
265
  categories = [...categories, ...res.data.data];
260
266
  commit('setCategories', categories);
261
- commit("setSelectedCategory", categories[0]);
267
+ if(categories.length){
268
+ if(!state.selectedCategory) {
269
+ commit("setSelectedCategory", categories[0]);
270
+ }else{
271
+ const catInList = categories.find(cat => cat.id === state.selectedCategory.id);
272
+ if(!catInList || JSON.stringify(state.selectedCategory) !== JSON.stringify(catInList)){
273
+ commit("setSelectedCategory", categories[0]);
274
+ }
275
+ }
276
+ }
277
+
262
278
  dispatch("getProducts", {
263
279
  category: categories[0],
264
280
  restaurantId: restaurantId,
@@ -269,7 +285,17 @@ const actions = {
269
285
  });
270
286
  } else {
271
287
  commit('setCategories', categories);
272
- commit("setSelectedCategory", categories[0]);
288
+ if(categories.length){
289
+ if(!state.selectedCategory) {
290
+ commit("setSelectedCategory", categories[0]);
291
+ }else{
292
+ const catInList = categories.find(cat => cat.id === state.selectedCategory.id);
293
+ if(!catInList || JSON.stringify(state.selectedCategory) !== JSON.stringify(catInList)){
294
+ commit("setSelectedCategory", categories[0]);
295
+ }
296
+ }
297
+ }
298
+
273
299
  dispatch("getProducts", {
274
300
  category: categories[0],
275
301
  restaurantId: restaurantId,