orderiom-api-package 0.4.36 → 0.4.37
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 +1 -1
- package/src/common.js +34 -33
- package/src/messages/de-api.json +5 -2
- package/src/messages/en-api.json +6 -3
- package/src/messages/fr-api.json +5 -2
- package/src/modules/order.js +158 -108
package/package.json
CHANGED
package/src/common.js
CHANGED
|
@@ -16,7 +16,7 @@ export function commonErrorCallback(unknownErrorMessage = 'Something went wrong'
|
|
|
16
16
|
if (status === 422) {
|
|
17
17
|
return {
|
|
18
18
|
type: 'error',
|
|
19
|
-
msg: Object.values(error.response.data.error.validation)
|
|
19
|
+
msg: Object.values(error.response.data.error.validation)[0],
|
|
20
20
|
}
|
|
21
21
|
} else if ([401, 403, 404, 400].includes(status)) {
|
|
22
22
|
return {
|
|
@@ -127,43 +127,44 @@ axios.interceptors.request.use(config => {
|
|
|
127
127
|
}, error => {
|
|
128
128
|
return Promise.reject(error);
|
|
129
129
|
});
|
|
130
|
-
axios.interceptors.response.use(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
130
|
+
axios.interceptors.response.use(
|
|
131
|
+
res => res,
|
|
132
|
+
error => {
|
|
133
|
+
if (
|
|
134
|
+
error.response &&
|
|
135
|
+
error.response.data &&
|
|
136
|
+
error.response.data.error &&
|
|
137
|
+
error.response.data.error.validation
|
|
138
|
+
) {
|
|
139
|
+
const validation = error.response.data.error.validation;
|
|
140
|
+
|
|
141
|
+
if (
|
|
142
|
+
(
|
|
143
|
+
Object.keys(validation).includes("basketId") &&
|
|
144
|
+
validation["basketId"][0] === "basket_does_not_exists"
|
|
145
|
+
) ||
|
|
146
|
+
(
|
|
147
|
+
Object.keys(validation).includes("restaurantId") &&
|
|
148
|
+
validation["restaurantId"][0] === "basket_does_not_exists"
|
|
149
|
+
)
|
|
150
|
+
) {
|
|
151
|
+
localStorage.removeItem("basket");
|
|
152
|
+
}
|
|
153
|
+
}
|
|
140
154
|
|
|
141
155
|
if (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
(
|
|
147
|
-
Object.keys(validation).includes("restaurantId") &&
|
|
148
|
-
validation["restaurantId"][0] === "basket_does_not_exists"
|
|
149
|
-
)
|
|
156
|
+
error.response &&
|
|
157
|
+
error.response.data &&
|
|
158
|
+
error.response.data.message &&
|
|
159
|
+
error.response.data.message.body === "unauthenticated" &&
|
|
160
|
+
localStorage.getItem("privateToken")
|
|
150
161
|
) {
|
|
151
|
-
localStorage.
|
|
162
|
+
localStorage.clear();
|
|
163
|
+
window.location.reload();
|
|
152
164
|
}
|
|
153
|
-
}
|
|
154
165
|
|
|
155
|
-
|
|
156
|
-
error.response &&
|
|
157
|
-
error.response.data &&
|
|
158
|
-
error.response.data.message &&
|
|
159
|
-
error.response.data.message.body === "unauthenticated" &&
|
|
160
|
-
localStorage.getItem("privateToken")
|
|
161
|
-
) {
|
|
162
|
-
localStorage.clear();
|
|
163
|
-
window.location.reload();
|
|
166
|
+
return Promise.reject(error);
|
|
164
167
|
}
|
|
165
|
-
|
|
166
|
-
return Promise.reject(error);
|
|
167
|
-
});
|
|
168
|
+
);
|
|
168
169
|
|
|
169
170
|
export const $http = axios;
|
package/src/messages/de-api.json
CHANGED
|
@@ -132,8 +132,11 @@
|
|
|
132
132
|
"Choose Your Address": "Wählen Sie Ihre Adresse",
|
|
133
133
|
"Password doesn't match": "Passwort nicht übereinstimmen",
|
|
134
134
|
"Please fill out this field": "Bitte füllen Sie dieses Feld aus",
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
|
|
136
|
+
"resources_have_been_reached": "Leider sind wir zu deiner gewählten Zeit sehr ausgelastet und können dein Essen nicht zubereiten. Möchtest du deine Zeit vielleicht auf {validTime} ändern?",
|
|
137
|
+
"is_not_available_for_your_selected_date": "Leider ist {name} für Ihr ausgewähltes Datum nicht verfügbar.",
|
|
138
|
+
"the_product_is_not_available": "Leider ist {name} nicht auf Lager",
|
|
139
|
+
|
|
137
140
|
"request_submitted": "Ihre Anfrage wurde übermittelt!",
|
|
138
141
|
"restaurant_past_time": "Das Restaurant ist nicht zur gewünschten Zeit geöffnet.",
|
|
139
142
|
"we have updates! please refresh.": "wir haben Updates! bitte aktualisieren.",
|
package/src/messages/en-api.json
CHANGED
|
@@ -132,9 +132,12 @@
|
|
|
132
132
|
"Choose Your Address": "Choose Your Address",
|
|
133
133
|
"Password doesn't match": "Password doesn't match",
|
|
134
134
|
"Please fill out this field": "Please fill out this field",
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
|
|
136
|
+
"resources_have_been_reached": "Unfortunately, we are very busy at your selected time and cannot prepare your food. Do you want to change your time to {validTime} maybe?",
|
|
137
|
+
"is_not_available_for_your_selected_date": "Unfortunately, {name} is not available for your selected date.",
|
|
138
|
+
"the_product_is_not_available": "Unfortunately, {name} is out of stock",
|
|
139
|
+
|
|
140
|
+
"request_submitted": "your request has been submitted!",
|
|
138
141
|
"restaurant_past_time": "Restaurant is not open at your desired Time.",
|
|
139
142
|
"we have updates! please refresh.": "we have updates! please refresh.",
|
|
140
143
|
"invoice": "invoice",
|
package/src/messages/fr-api.json
CHANGED
|
@@ -132,8 +132,11 @@
|
|
|
132
132
|
"Choose Your Address": "Choisissez votre adresse",
|
|
133
133
|
"Password doesn't match": "Le mot de passe ne correspond pas",
|
|
134
134
|
"Please fill out this field": "Veuillez remplir ce champ",
|
|
135
|
-
|
|
136
|
-
"
|
|
135
|
+
|
|
136
|
+
"resources_have_been_reached": "Malheureusement, nous sommes très occupés à l'heure que vous avez choisie et ne pouvons pas préparer votre nourriture. Voulez-vous peut-être changer votre heure en {validTime}?",
|
|
137
|
+
"is_not_available_for_your_selected_date": "Malheureusement, {name} n'est pas disponible pour la date sélectionnée.",
|
|
138
|
+
"the_product_is_not_available": "Malheureusement, {name} est en rupture de stock",
|
|
139
|
+
|
|
137
140
|
"request_submitted": "votre demande a été soumise!",
|
|
138
141
|
"restaurant_past_time": "Le restaurant n'est pas ouvert à l'heure souhaitée.",
|
|
139
142
|
"we have updates! please refresh.": "nous avons des mises à jour! veuillez rafraîchir.",
|
package/src/modules/order.js
CHANGED
|
@@ -566,82 +566,108 @@ const actions = {
|
|
|
566
566
|
data.array.splice(index, 1);
|
|
567
567
|
}
|
|
568
568
|
},
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
569
|
+
createOrder({commit, rootState}, data) {
|
|
570
|
+
let basketId = undefined;
|
|
571
|
+
try {
|
|
572
|
+
basketId = calculateBasketIdParameter(
|
|
573
|
+
!!rootState.orderiomApiPackage.auth.privateToken,
|
|
574
|
+
data.restaurantId
|
|
575
|
+
);
|
|
576
|
+
} catch (e) {
|
|
577
|
+
console.error(e);
|
|
578
|
+
return {type: "error", msg: "Basket not found"};
|
|
579
|
+
}
|
|
580
580
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
581
|
+
return $http.post("api/order/create-order", {
|
|
582
|
+
basketId,
|
|
583
|
+
restaurantId: data.restaurantId,
|
|
584
|
+
paymentType: data.paymentType,
|
|
585
|
+
...(data.paymentType === "payFix" && {
|
|
586
|
+
qrCode: data.payfix_qrcode,
|
|
587
|
+
pin: data.payfix_pin,
|
|
588
|
+
}),
|
|
589
|
+
tablePaymentId: data.tablePaymentId ? data.tablePaymentId : null,
|
|
590
|
+
externalBasketItems: data.externalBasketItems ? data.externalBasketItems : null
|
|
591
|
+
}).then(res => {
|
|
592
|
+
// localStorage.setItem("orderId", res.data.data.order.id);
|
|
593
|
+
// commit('setproductOrder', res.data.data.product)
|
|
594
|
+
// commit('settotalPriceOrder', res.data.data.order.total_price)
|
|
595
|
+
// commit('setorder', res.data.data.order)
|
|
596
|
+
// commit('setuserOrder', JSON.parse(res.data.data.order.user_details));
|
|
597
|
+
// commit('setshippigPriceOrder', res.data.data.order.shipping_price);
|
|
598
|
+
const basketData = JSON.parse(localStorage.getItem("basket"));
|
|
599
|
+
if (basketData) {
|
|
600
|
+
const index = basketId
|
|
601
|
+
? basketData.findIndex(item => Number(item.basketId) === Number(basketId))
|
|
602
|
+
: basketData.findIndex(item => Number(item.restaurantId) === Number(data.restaurantId || restaurantIdEnv()))
|
|
603
|
+
if (index > -1) {
|
|
604
|
+
basketData.splice(index, 1);
|
|
605
|
+
localStorage.setItem("basket", JSON.stringify(basketData));
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
608
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
609
|
+
commit("product/SetSubtotalPrice", "0.00", {root: true});
|
|
610
|
+
commit("product/SetShoppingCart", [], {root: true});
|
|
611
|
+
commit("product/setBasketInfo", {}, {root: true});
|
|
612
|
+
commit("product/setDeliveryTime", "", {root: true});
|
|
613
|
+
commit("product/SetTotalPrice", "0.00", {root: true});
|
|
614
614
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
615
|
+
if (
|
|
616
|
+
(
|
|
617
|
+
res.data.data.paymentLink.includes("/paymentstatus/?") ||
|
|
618
|
+
res.data.data.paymentLink.includes("/paymentstatus?")
|
|
619
|
+
) &&
|
|
620
|
+
data.$router &&
|
|
621
|
+
data.routeName
|
|
622
|
+
) {
|
|
623
|
+
data.$router.push({
|
|
624
|
+
name: data.routeName,
|
|
625
|
+
query: res.data.data.paymentLink
|
|
626
|
+
.split("?")[1]
|
|
627
|
+
.split("&")
|
|
628
|
+
.map((query) => query.split("="))
|
|
629
|
+
.reduce((result, element) => {
|
|
630
|
+
if (!element) return result;
|
|
631
|
+
result[element[0]] = element[1];
|
|
632
|
+
return result;
|
|
633
|
+
}, {}),
|
|
634
|
+
});
|
|
635
|
+
} else {
|
|
636
|
+
window.location = res.data.data.paymentLink;
|
|
637
|
+
}
|
|
638
638
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
639
|
+
return {
|
|
640
|
+
type: "success",
|
|
641
|
+
msg: "ok",
|
|
642
|
+
};
|
|
643
|
+
}).catch(error => {
|
|
644
|
+
const status = error.response ? error.response.status : null;
|
|
645
|
+
if (status === 422) {
|
|
646
|
+
const validation = error.response.data.error.validation;
|
|
647
|
+
|
|
648
|
+
const name = validation.name;
|
|
649
|
+
const validTime = validation.validTime;
|
|
650
|
+
delete validation.name;
|
|
651
|
+
delete validation.validTime;
|
|
652
|
+
|
|
653
|
+
return {
|
|
654
|
+
type: 'error',
|
|
655
|
+
msg: Object.values(validation)[0],
|
|
656
|
+
name,
|
|
657
|
+
validTime
|
|
658
|
+
}
|
|
659
|
+
} else if ([401, 403, 404, 400].includes(status)) {
|
|
660
|
+
return {
|
|
661
|
+
type: 'error',
|
|
662
|
+
msg: error.response.data.message.body
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
return {
|
|
666
|
+
type: 'error',
|
|
667
|
+
msg: 'Something went wrong'
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
},
|
|
645
671
|
getOrder({ commit }, orderId) {
|
|
646
672
|
return $http
|
|
647
673
|
.get("api/order", {
|
|
@@ -814,45 +840,69 @@ const actions = {
|
|
|
814
840
|
})
|
|
815
841
|
.catch(commonErrorCallback());
|
|
816
842
|
},
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
843
|
+
addDeliveryTimeToBasket({commit, dispatch, rootState}, data) {
|
|
844
|
+
let basketId = undefined;
|
|
845
|
+
try {
|
|
846
|
+
basketId = calculateBasketIdParameter(
|
|
847
|
+
!!rootState.orderiomApiPackage.auth.privateToken,
|
|
848
|
+
data.restaurantId
|
|
849
|
+
);
|
|
850
|
+
} catch (e) {
|
|
851
|
+
console.error(e);
|
|
852
|
+
return {type: "error", msg: "Basket not found"};
|
|
853
|
+
}
|
|
828
854
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
855
|
+
let delivery_time = null;
|
|
856
|
+
if (data.delivery_time instanceof Date) {
|
|
857
|
+
delivery_time = [
|
|
858
|
+
formatDate(data.delivery_time),
|
|
859
|
+
formatTime(data.delivery_time)
|
|
860
|
+
].join(' ')
|
|
861
|
+
} else if (data.date && data.time) {
|
|
862
|
+
delivery_time = data.date + ' ' + data.time
|
|
863
|
+
}
|
|
838
864
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
865
|
+
commit('setChangingDeliveryTime', true)
|
|
866
|
+
return $http.post("api/basket/add-delivery-time", {
|
|
867
|
+
basketId,
|
|
868
|
+
delivery_time,
|
|
869
|
+
deliveryType: data.deliveryType,
|
|
870
|
+
duration: data.duration || undefined,
|
|
871
|
+
restaurantId: data.restaurantId,
|
|
872
|
+
}).then(() => {
|
|
873
|
+
dispatch("product/getBasket", data.restaurantId, {root: true});
|
|
848
874
|
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
875
|
+
return {type: "success", msg: ""};
|
|
876
|
+
}).catch(error => {
|
|
877
|
+
const status = error.response ? error.response.status : null;
|
|
878
|
+
if (status === 422) {
|
|
879
|
+
const validation = error.response.data.error.validation;
|
|
880
|
+
|
|
881
|
+
const name = validation.name;
|
|
882
|
+
const validTime = validation.validTime;
|
|
883
|
+
delete validation.name;
|
|
884
|
+
delete validation.validTime;
|
|
885
|
+
|
|
886
|
+
return {
|
|
887
|
+
type: 'error',
|
|
888
|
+
msg: Object.values(validation)[0],
|
|
889
|
+
name,
|
|
890
|
+
validTime
|
|
891
|
+
}
|
|
892
|
+
} else if ([401, 403, 404, 400].includes(status)) {
|
|
893
|
+
return {
|
|
894
|
+
type: 'error',
|
|
895
|
+
msg: error.response.data.message.body
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
return {
|
|
899
|
+
type: 'error',
|
|
900
|
+
msg: 'Something went wrong'
|
|
901
|
+
}
|
|
902
|
+
}).finally(() => {
|
|
903
|
+
commit('setChangingDeliveryTime', false)
|
|
904
|
+
});
|
|
905
|
+
},
|
|
856
906
|
getOrderHistory({ commit }, data) {
|
|
857
907
|
return $http
|
|
858
908
|
.get("api/order/history", { params: data })
|