orderiom-api-package 0.4.89 → 0.4.90

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.89",
3
+ "version": "0.4.90",
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",
@@ -603,31 +603,43 @@ const actions = {
603
603
  commit("product/setDeliveryTime", "", {root: true});
604
604
  commit("product/SetTotalPrice", "0.00", {root: true});
605
605
 
606
- if (
607
- (
608
- res.data.data.paymentLink.includes("/paymentstatus/?") ||
609
- res.data.data.paymentLink.includes("/paymentstatus?")
610
- ) &&
611
- data.$router &&
612
- data.routeName
613
- ) {
614
- data.$router.push({
615
- name: data.routeName,
616
- query: res.data.data.paymentLink
617
- .split("?")[1]
618
- .split("&")
619
- .map((query) => query.split("="))
620
- .reduce((result, element) => {
621
- if (!element) return result;
622
- result[element[0]] = element[1];
623
- return result;
624
- }, {}),
625
- });
626
- } else {
606
+ const classicRedirect = (res) => {
627
607
  window.location = res.data.data.paymentLink;
608
+ return res;
628
609
  }
629
610
 
630
- return res;
611
+ if(!data.$router || !data.routeName) return classicRedirect(res);
612
+
613
+ // find route name for vue-router
614
+ let name = null;
615
+ if(
616
+ res.data.data.paymentLink.includes("/paymentstatus/?") ||
617
+ res.data.data.paymentLink.includes("/paymentstatus?")
618
+ ){
619
+ // Check string data.routeName to ensure backward compatibility
620
+ name = typeof data.routeName === 'string' ? data.routeName : data.routeName['paymentstatus']
621
+ }else if(
622
+ res.data.data.paymentLink.includes("/payment/?") ||
623
+ res.data.data.paymentLink.includes("/payment?")
624
+ ){
625
+ // Check string data.routeName to ensure backward compatibility
626
+ name = typeof data.routeName === 'string' ? null : data.routeName['payment']
627
+ }
628
+
629
+ if(!name) return classicRedirect(res);
630
+
631
+ data.$router.push({
632
+ name,
633
+ query: res.data.data.paymentLink
634
+ .split("?")[1]
635
+ .split("&")
636
+ .map((query) => query.split("="))
637
+ .reduce((result, element) => {
638
+ if (!element) return result;
639
+ result[element[0]] = element[1];
640
+ return result;
641
+ }, {}),
642
+ });
631
643
  }).catch(error => {
632
644
  const status = error.response ? error.response.status : null;
633
645
  if (status === 422) {