@moonbase.sh/vue 0.2.132 → 0.2.135
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/dist/index.cjs +21 -9
- package/dist/index.d.cts +71 -1
- package/dist/index.d.ts +71 -1
- package/dist/index.js +22 -10
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -407,7 +407,7 @@ function useActivationRequest(token, context) {
|
|
|
407
407
|
console.warn("No token given to `useActivationRequest`");
|
|
408
408
|
}
|
|
409
409
|
} catch (err) {
|
|
410
|
-
error.value = err;
|
|
410
|
+
error.value = err.message;
|
|
411
411
|
loading.value = false;
|
|
412
412
|
}
|
|
413
413
|
}, { immediate: true });
|
|
@@ -428,7 +428,7 @@ function useActivationRequest(token, context) {
|
|
|
428
428
|
checkCompletion();
|
|
429
429
|
}
|
|
430
430
|
} catch (e) {
|
|
431
|
-
error.value = e;
|
|
431
|
+
error.value = e.message;
|
|
432
432
|
}
|
|
433
433
|
loading.value = false;
|
|
434
434
|
});
|
|
@@ -451,10 +451,20 @@ function useActivationRequest(token, context) {
|
|
|
451
451
|
},
|
|
452
452
|
fulfillTrial: async () => {
|
|
453
453
|
fulfilling.value = true;
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
454
|
+
try {
|
|
455
|
+
activationRequest.value = await storefront.client.activationRequests.fulfillTrial(activationRequest.value.id);
|
|
456
|
+
fulfilling.value = false;
|
|
457
|
+
completing.value = true;
|
|
458
|
+
const _ = checkCompletion();
|
|
459
|
+
} catch (err) {
|
|
460
|
+
console.warn("Could not fulfill trial: ", err);
|
|
461
|
+
if (err instanceof import_storefront_api3.NotAuthenticatedError) {
|
|
462
|
+
error.value = "You need to be signed in to do this";
|
|
463
|
+
} else {
|
|
464
|
+
error.value = err.message;
|
|
465
|
+
}
|
|
466
|
+
fulfilling.value = false;
|
|
467
|
+
}
|
|
458
468
|
},
|
|
459
469
|
cancel: async () => {
|
|
460
470
|
if (!activationRequest.value || activationRequest.value.status === import_storefront_api3.ActivationRequestStatus.Cancelled)
|
|
@@ -586,18 +596,20 @@ function useCart(context) {
|
|
|
586
596
|
total: (0, import_vue6.computed)(() => {
|
|
587
597
|
const currency = storefront.currentOrder.value.currency || storefront.storefront.value.suggestedCurrency;
|
|
588
598
|
const total = storefront.currentOrder.value.items.reduce((agg, item) => {
|
|
589
|
-
var _a, _b, _c, _d, _e, _f;
|
|
599
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
590
600
|
let price;
|
|
591
601
|
if (item.type === "Product") {
|
|
592
602
|
const product = storefront.storefront.value.products.find((p) => p.id === item.productId);
|
|
593
603
|
const variations = (product == null ? void 0 : product.variations) || [];
|
|
594
604
|
const pickedVariation = variations.find((v) => v.id === item.variationId);
|
|
595
|
-
|
|
605
|
+
const eligiblePricingTiers = (_b = (_a = pickedVariation == null ? void 0 : pickedVariation.pricingTiers) == null ? void 0 : _a.filter((tier) => item.quantity >= tier.minQuantity)) != null ? _b : [];
|
|
606
|
+
const matchingPricingTier = eligiblePricingTiers.length > 0 ? eligiblePricingTiers[eligiblePricingTiers.length - 1] : null;
|
|
607
|
+
price = (_f = (_e = (_c = matchingPricingTier == null ? void 0 : matchingPricingTier.price[currency]) != null ? _c : pickedVariation == null ? void 0 : pickedVariation.price[currency]) != null ? _e : (_d = product == null ? void 0 : product.defaultVariation) == null ? void 0 : _d.price[currency]) != null ? _f : 0;
|
|
596
608
|
} else {
|
|
597
609
|
const bundle = storefront.storefront.value.bundles.find((b) => b.id === item.bundleId);
|
|
598
610
|
const variations = (bundle == null ? void 0 : bundle.variations) || [];
|
|
599
611
|
const pickedVariation = variations.find((v) => v.id === item.variationId);
|
|
600
|
-
price = (
|
|
612
|
+
price = (_i = (_h = pickedVariation == null ? void 0 : pickedVariation.price[currency]) != null ? _h : (_g = bundle == null ? void 0 : bundle.defaultVariation) == null ? void 0 : _g.price[currency]) != null ? _i : 0;
|
|
601
613
|
}
|
|
602
614
|
return agg + price * item.quantity;
|
|
603
615
|
}, 0);
|
package/dist/index.d.cts
CHANGED
|
@@ -43,7 +43,7 @@ interface ActivationRequestComposable {
|
|
|
43
43
|
loading: Ref<boolean>;
|
|
44
44
|
fulfilling: Ref<boolean>;
|
|
45
45
|
completing: Ref<boolean>;
|
|
46
|
-
error: Ref<null |
|
|
46
|
+
error: Ref<null | string>;
|
|
47
47
|
isInstalled: Ref<boolean>;
|
|
48
48
|
fulfillLicense: () => Promise<void>;
|
|
49
49
|
fulfillTrial: () => Promise<void>;
|
|
@@ -197,6 +197,11 @@ declare function useCart(context?: StorefrontContext): {
|
|
|
197
197
|
description?: string | undefined;
|
|
198
198
|
total?: Record<string, number> | undefined;
|
|
199
199
|
} | undefined;
|
|
200
|
+
pricingTiers?: {
|
|
201
|
+
minQuantity: number;
|
|
202
|
+
originalPrice: Record<string, number>;
|
|
203
|
+
price: Record<string, number>;
|
|
204
|
+
}[] | null | undefined;
|
|
200
205
|
} | undefined;
|
|
201
206
|
appliedDiscount?: {
|
|
202
207
|
type: "PercentageOffDiscount";
|
|
@@ -254,6 +259,11 @@ declare function useCart(context?: StorefrontContext): {
|
|
|
254
259
|
description?: string | undefined;
|
|
255
260
|
total?: Record<string, number> | undefined;
|
|
256
261
|
} | undefined;
|
|
262
|
+
pricingTiers?: {
|
|
263
|
+
minQuantity: number;
|
|
264
|
+
originalPrice: Record<string, number>;
|
|
265
|
+
price: Record<string, number>;
|
|
266
|
+
}[] | null | undefined;
|
|
257
267
|
} | undefined;
|
|
258
268
|
appliedDiscount?: {
|
|
259
269
|
type: "PercentageOffDiscount";
|
|
@@ -573,6 +583,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
573
583
|
description?: string | undefined;
|
|
574
584
|
total?: Record<string, number> | undefined;
|
|
575
585
|
} | undefined;
|
|
586
|
+
pricingTiers?: {
|
|
587
|
+
minQuantity: number;
|
|
588
|
+
originalPrice: Record<string, number>;
|
|
589
|
+
price: Record<string, number>;
|
|
590
|
+
}[] | null | undefined;
|
|
576
591
|
} | undefined;
|
|
577
592
|
variations?: {
|
|
578
593
|
id: string;
|
|
@@ -594,6 +609,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
594
609
|
description?: string | undefined;
|
|
595
610
|
total?: Record<string, number> | undefined;
|
|
596
611
|
} | undefined;
|
|
612
|
+
pricingTiers?: {
|
|
613
|
+
minQuantity: number;
|
|
614
|
+
originalPrice: Record<string, number>;
|
|
615
|
+
price: Record<string, number>;
|
|
616
|
+
}[] | null | undefined;
|
|
597
617
|
}[] | undefined;
|
|
598
618
|
};
|
|
599
619
|
quantity: number;
|
|
@@ -652,6 +672,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
652
672
|
description?: string | undefined;
|
|
653
673
|
total?: Record<string, number> | undefined;
|
|
654
674
|
} | undefined;
|
|
675
|
+
pricingTiers?: {
|
|
676
|
+
minQuantity: number;
|
|
677
|
+
originalPrice: Record<string, number>;
|
|
678
|
+
price: Record<string, number>;
|
|
679
|
+
}[] | null | undefined;
|
|
655
680
|
} | undefined;
|
|
656
681
|
variations?: {
|
|
657
682
|
id: string;
|
|
@@ -673,6 +698,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
673
698
|
description?: string | undefined;
|
|
674
699
|
total?: Record<string, number> | undefined;
|
|
675
700
|
} | undefined;
|
|
701
|
+
pricingTiers?: {
|
|
702
|
+
minQuantity: number;
|
|
703
|
+
originalPrice: Record<string, number>;
|
|
704
|
+
price: Record<string, number>;
|
|
705
|
+
}[] | null | undefined;
|
|
676
706
|
}[] | undefined;
|
|
677
707
|
} & {
|
|
678
708
|
included?: boolean | undefined;
|
|
@@ -697,6 +727,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
697
727
|
description?: string | undefined;
|
|
698
728
|
total?: Record<string, number> | undefined;
|
|
699
729
|
} | undefined;
|
|
730
|
+
pricingTiers?: {
|
|
731
|
+
minQuantity: number;
|
|
732
|
+
originalPrice: Record<string, number>;
|
|
733
|
+
price: Record<string, number>;
|
|
734
|
+
}[] | null | undefined;
|
|
700
735
|
} | undefined;
|
|
701
736
|
variations?: {
|
|
702
737
|
id: string;
|
|
@@ -718,6 +753,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
718
753
|
description?: string | undefined;
|
|
719
754
|
total?: Record<string, number> | undefined;
|
|
720
755
|
} | undefined;
|
|
756
|
+
pricingTiers?: {
|
|
757
|
+
minQuantity: number;
|
|
758
|
+
originalPrice: Record<string, number>;
|
|
759
|
+
price: Record<string, number>;
|
|
760
|
+
}[] | null | undefined;
|
|
721
761
|
}[] | undefined;
|
|
722
762
|
};
|
|
723
763
|
quantity: number;
|
|
@@ -774,6 +814,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
774
814
|
description?: string | undefined;
|
|
775
815
|
total?: Record<string, number> | undefined;
|
|
776
816
|
} | undefined;
|
|
817
|
+
pricingTiers?: {
|
|
818
|
+
minQuantity: number;
|
|
819
|
+
originalPrice: Record<string, number>;
|
|
820
|
+
price: Record<string, number>;
|
|
821
|
+
}[] | null | undefined;
|
|
777
822
|
} | undefined;
|
|
778
823
|
variations?: {
|
|
779
824
|
id: string;
|
|
@@ -795,6 +840,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
795
840
|
description?: string | undefined;
|
|
796
841
|
total?: Record<string, number> | undefined;
|
|
797
842
|
} | undefined;
|
|
843
|
+
pricingTiers?: {
|
|
844
|
+
minQuantity: number;
|
|
845
|
+
originalPrice: Record<string, number>;
|
|
846
|
+
price: Record<string, number>;
|
|
847
|
+
}[] | null | undefined;
|
|
798
848
|
}[] | undefined;
|
|
799
849
|
};
|
|
800
850
|
quantity: number;
|
|
@@ -853,6 +903,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
853
903
|
description?: string | undefined;
|
|
854
904
|
total?: Record<string, number> | undefined;
|
|
855
905
|
} | undefined;
|
|
906
|
+
pricingTiers?: {
|
|
907
|
+
minQuantity: number;
|
|
908
|
+
originalPrice: Record<string, number>;
|
|
909
|
+
price: Record<string, number>;
|
|
910
|
+
}[] | null | undefined;
|
|
856
911
|
} | undefined;
|
|
857
912
|
variations?: {
|
|
858
913
|
id: string;
|
|
@@ -874,6 +929,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
874
929
|
description?: string | undefined;
|
|
875
930
|
total?: Record<string, number> | undefined;
|
|
876
931
|
} | undefined;
|
|
932
|
+
pricingTiers?: {
|
|
933
|
+
minQuantity: number;
|
|
934
|
+
originalPrice: Record<string, number>;
|
|
935
|
+
price: Record<string, number>;
|
|
936
|
+
}[] | null | undefined;
|
|
877
937
|
}[] | undefined;
|
|
878
938
|
} & {
|
|
879
939
|
included?: boolean | undefined;
|
|
@@ -898,6 +958,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
898
958
|
description?: string | undefined;
|
|
899
959
|
total?: Record<string, number> | undefined;
|
|
900
960
|
} | undefined;
|
|
961
|
+
pricingTiers?: {
|
|
962
|
+
minQuantity: number;
|
|
963
|
+
originalPrice: Record<string, number>;
|
|
964
|
+
price: Record<string, number>;
|
|
965
|
+
}[] | null | undefined;
|
|
901
966
|
} | undefined;
|
|
902
967
|
variations?: {
|
|
903
968
|
id: string;
|
|
@@ -919,6 +984,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
919
984
|
description?: string | undefined;
|
|
920
985
|
total?: Record<string, number> | undefined;
|
|
921
986
|
} | undefined;
|
|
987
|
+
pricingTiers?: {
|
|
988
|
+
minQuantity: number;
|
|
989
|
+
originalPrice: Record<string, number>;
|
|
990
|
+
price: Record<string, number>;
|
|
991
|
+
}[] | null | undefined;
|
|
922
992
|
}[] | undefined;
|
|
923
993
|
};
|
|
924
994
|
quantity: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ interface ActivationRequestComposable {
|
|
|
43
43
|
loading: Ref<boolean>;
|
|
44
44
|
fulfilling: Ref<boolean>;
|
|
45
45
|
completing: Ref<boolean>;
|
|
46
|
-
error: Ref<null |
|
|
46
|
+
error: Ref<null | string>;
|
|
47
47
|
isInstalled: Ref<boolean>;
|
|
48
48
|
fulfillLicense: () => Promise<void>;
|
|
49
49
|
fulfillTrial: () => Promise<void>;
|
|
@@ -197,6 +197,11 @@ declare function useCart(context?: StorefrontContext): {
|
|
|
197
197
|
description?: string | undefined;
|
|
198
198
|
total?: Record<string, number> | undefined;
|
|
199
199
|
} | undefined;
|
|
200
|
+
pricingTiers?: {
|
|
201
|
+
minQuantity: number;
|
|
202
|
+
originalPrice: Record<string, number>;
|
|
203
|
+
price: Record<string, number>;
|
|
204
|
+
}[] | null | undefined;
|
|
200
205
|
} | undefined;
|
|
201
206
|
appliedDiscount?: {
|
|
202
207
|
type: "PercentageOffDiscount";
|
|
@@ -254,6 +259,11 @@ declare function useCart(context?: StorefrontContext): {
|
|
|
254
259
|
description?: string | undefined;
|
|
255
260
|
total?: Record<string, number> | undefined;
|
|
256
261
|
} | undefined;
|
|
262
|
+
pricingTiers?: {
|
|
263
|
+
minQuantity: number;
|
|
264
|
+
originalPrice: Record<string, number>;
|
|
265
|
+
price: Record<string, number>;
|
|
266
|
+
}[] | null | undefined;
|
|
257
267
|
} | undefined;
|
|
258
268
|
appliedDiscount?: {
|
|
259
269
|
type: "PercentageOffDiscount";
|
|
@@ -573,6 +583,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
573
583
|
description?: string | undefined;
|
|
574
584
|
total?: Record<string, number> | undefined;
|
|
575
585
|
} | undefined;
|
|
586
|
+
pricingTiers?: {
|
|
587
|
+
minQuantity: number;
|
|
588
|
+
originalPrice: Record<string, number>;
|
|
589
|
+
price: Record<string, number>;
|
|
590
|
+
}[] | null | undefined;
|
|
576
591
|
} | undefined;
|
|
577
592
|
variations?: {
|
|
578
593
|
id: string;
|
|
@@ -594,6 +609,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
594
609
|
description?: string | undefined;
|
|
595
610
|
total?: Record<string, number> | undefined;
|
|
596
611
|
} | undefined;
|
|
612
|
+
pricingTiers?: {
|
|
613
|
+
minQuantity: number;
|
|
614
|
+
originalPrice: Record<string, number>;
|
|
615
|
+
price: Record<string, number>;
|
|
616
|
+
}[] | null | undefined;
|
|
597
617
|
}[] | undefined;
|
|
598
618
|
};
|
|
599
619
|
quantity: number;
|
|
@@ -652,6 +672,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
652
672
|
description?: string | undefined;
|
|
653
673
|
total?: Record<string, number> | undefined;
|
|
654
674
|
} | undefined;
|
|
675
|
+
pricingTiers?: {
|
|
676
|
+
minQuantity: number;
|
|
677
|
+
originalPrice: Record<string, number>;
|
|
678
|
+
price: Record<string, number>;
|
|
679
|
+
}[] | null | undefined;
|
|
655
680
|
} | undefined;
|
|
656
681
|
variations?: {
|
|
657
682
|
id: string;
|
|
@@ -673,6 +698,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
673
698
|
description?: string | undefined;
|
|
674
699
|
total?: Record<string, number> | undefined;
|
|
675
700
|
} | undefined;
|
|
701
|
+
pricingTiers?: {
|
|
702
|
+
minQuantity: number;
|
|
703
|
+
originalPrice: Record<string, number>;
|
|
704
|
+
price: Record<string, number>;
|
|
705
|
+
}[] | null | undefined;
|
|
676
706
|
}[] | undefined;
|
|
677
707
|
} & {
|
|
678
708
|
included?: boolean | undefined;
|
|
@@ -697,6 +727,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
697
727
|
description?: string | undefined;
|
|
698
728
|
total?: Record<string, number> | undefined;
|
|
699
729
|
} | undefined;
|
|
730
|
+
pricingTiers?: {
|
|
731
|
+
minQuantity: number;
|
|
732
|
+
originalPrice: Record<string, number>;
|
|
733
|
+
price: Record<string, number>;
|
|
734
|
+
}[] | null | undefined;
|
|
700
735
|
} | undefined;
|
|
701
736
|
variations?: {
|
|
702
737
|
id: string;
|
|
@@ -718,6 +753,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
718
753
|
description?: string | undefined;
|
|
719
754
|
total?: Record<string, number> | undefined;
|
|
720
755
|
} | undefined;
|
|
756
|
+
pricingTiers?: {
|
|
757
|
+
minQuantity: number;
|
|
758
|
+
originalPrice: Record<string, number>;
|
|
759
|
+
price: Record<string, number>;
|
|
760
|
+
}[] | null | undefined;
|
|
721
761
|
}[] | undefined;
|
|
722
762
|
};
|
|
723
763
|
quantity: number;
|
|
@@ -774,6 +814,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
774
814
|
description?: string | undefined;
|
|
775
815
|
total?: Record<string, number> | undefined;
|
|
776
816
|
} | undefined;
|
|
817
|
+
pricingTiers?: {
|
|
818
|
+
minQuantity: number;
|
|
819
|
+
originalPrice: Record<string, number>;
|
|
820
|
+
price: Record<string, number>;
|
|
821
|
+
}[] | null | undefined;
|
|
777
822
|
} | undefined;
|
|
778
823
|
variations?: {
|
|
779
824
|
id: string;
|
|
@@ -795,6 +840,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
795
840
|
description?: string | undefined;
|
|
796
841
|
total?: Record<string, number> | undefined;
|
|
797
842
|
} | undefined;
|
|
843
|
+
pricingTiers?: {
|
|
844
|
+
minQuantity: number;
|
|
845
|
+
originalPrice: Record<string, number>;
|
|
846
|
+
price: Record<string, number>;
|
|
847
|
+
}[] | null | undefined;
|
|
798
848
|
}[] | undefined;
|
|
799
849
|
};
|
|
800
850
|
quantity: number;
|
|
@@ -853,6 +903,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
853
903
|
description?: string | undefined;
|
|
854
904
|
total?: Record<string, number> | undefined;
|
|
855
905
|
} | undefined;
|
|
906
|
+
pricingTiers?: {
|
|
907
|
+
minQuantity: number;
|
|
908
|
+
originalPrice: Record<string, number>;
|
|
909
|
+
price: Record<string, number>;
|
|
910
|
+
}[] | null | undefined;
|
|
856
911
|
} | undefined;
|
|
857
912
|
variations?: {
|
|
858
913
|
id: string;
|
|
@@ -874,6 +929,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
874
929
|
description?: string | undefined;
|
|
875
930
|
total?: Record<string, number> | undefined;
|
|
876
931
|
} | undefined;
|
|
932
|
+
pricingTiers?: {
|
|
933
|
+
minQuantity: number;
|
|
934
|
+
originalPrice: Record<string, number>;
|
|
935
|
+
price: Record<string, number>;
|
|
936
|
+
}[] | null | undefined;
|
|
877
937
|
}[] | undefined;
|
|
878
938
|
} & {
|
|
879
939
|
included?: boolean | undefined;
|
|
@@ -898,6 +958,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
898
958
|
description?: string | undefined;
|
|
899
959
|
total?: Record<string, number> | undefined;
|
|
900
960
|
} | undefined;
|
|
961
|
+
pricingTiers?: {
|
|
962
|
+
minQuantity: number;
|
|
963
|
+
originalPrice: Record<string, number>;
|
|
964
|
+
price: Record<string, number>;
|
|
965
|
+
}[] | null | undefined;
|
|
901
966
|
} | undefined;
|
|
902
967
|
variations?: {
|
|
903
968
|
id: string;
|
|
@@ -919,6 +984,11 @@ declare function useVoucher(context?: StorefrontContext): {
|
|
|
919
984
|
description?: string | undefined;
|
|
920
985
|
total?: Record<string, number> | undefined;
|
|
921
986
|
} | undefined;
|
|
987
|
+
pricingTiers?: {
|
|
988
|
+
minQuantity: number;
|
|
989
|
+
originalPrice: Record<string, number>;
|
|
990
|
+
price: Record<string, number>;
|
|
991
|
+
}[] | null | undefined;
|
|
922
992
|
}[] | undefined;
|
|
923
993
|
};
|
|
924
994
|
quantity: number;
|
package/dist/index.js
CHANGED
|
@@ -339,7 +339,7 @@ _StorefrontContextImpl.utmKey = "moonbase_utm";
|
|
|
339
339
|
var StorefrontContextImpl = _StorefrontContextImpl;
|
|
340
340
|
|
|
341
341
|
// src/composables/useActivationRequest.ts
|
|
342
|
-
import { ActivationRequestStatus } from "@moonbase.sh/storefront-api";
|
|
342
|
+
import { ActivationRequestStatus, NotAuthenticatedError as NotAuthenticatedError2 } from "@moonbase.sh/storefront-api";
|
|
343
343
|
import { computed, inject, onBeforeUnmount, toValue, watch as watch2 } from "vue";
|
|
344
344
|
function useActivationRequest(token, context) {
|
|
345
345
|
const storefront = context != null ? context : inject(storefrontKey);
|
|
@@ -375,7 +375,7 @@ function useActivationRequest(token, context) {
|
|
|
375
375
|
console.warn("No token given to `useActivationRequest`");
|
|
376
376
|
}
|
|
377
377
|
} catch (err) {
|
|
378
|
-
error.value = err;
|
|
378
|
+
error.value = err.message;
|
|
379
379
|
loading.value = false;
|
|
380
380
|
}
|
|
381
381
|
}, { immediate: true });
|
|
@@ -396,7 +396,7 @@ function useActivationRequest(token, context) {
|
|
|
396
396
|
checkCompletion();
|
|
397
397
|
}
|
|
398
398
|
} catch (e) {
|
|
399
|
-
error.value = e;
|
|
399
|
+
error.value = e.message;
|
|
400
400
|
}
|
|
401
401
|
loading.value = false;
|
|
402
402
|
});
|
|
@@ -419,10 +419,20 @@ function useActivationRequest(token, context) {
|
|
|
419
419
|
},
|
|
420
420
|
fulfillTrial: async () => {
|
|
421
421
|
fulfilling.value = true;
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
422
|
+
try {
|
|
423
|
+
activationRequest.value = await storefront.client.activationRequests.fulfillTrial(activationRequest.value.id);
|
|
424
|
+
fulfilling.value = false;
|
|
425
|
+
completing.value = true;
|
|
426
|
+
const _ = checkCompletion();
|
|
427
|
+
} catch (err) {
|
|
428
|
+
console.warn("Could not fulfill trial: ", err);
|
|
429
|
+
if (err instanceof NotAuthenticatedError2) {
|
|
430
|
+
error.value = "You need to be signed in to do this";
|
|
431
|
+
} else {
|
|
432
|
+
error.value = err.message;
|
|
433
|
+
}
|
|
434
|
+
fulfilling.value = false;
|
|
435
|
+
}
|
|
426
436
|
},
|
|
427
437
|
cancel: async () => {
|
|
428
438
|
if (!activationRequest.value || activationRequest.value.status === ActivationRequestStatus.Cancelled)
|
|
@@ -554,18 +564,20 @@ function useCart(context) {
|
|
|
554
564
|
total: computed4(() => {
|
|
555
565
|
const currency = storefront.currentOrder.value.currency || storefront.storefront.value.suggestedCurrency;
|
|
556
566
|
const total = storefront.currentOrder.value.items.reduce((agg, item) => {
|
|
557
|
-
var _a, _b, _c, _d, _e, _f;
|
|
567
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
558
568
|
let price;
|
|
559
569
|
if (item.type === "Product") {
|
|
560
570
|
const product = storefront.storefront.value.products.find((p) => p.id === item.productId);
|
|
561
571
|
const variations = (product == null ? void 0 : product.variations) || [];
|
|
562
572
|
const pickedVariation = variations.find((v) => v.id === item.variationId);
|
|
563
|
-
|
|
573
|
+
const eligiblePricingTiers = (_b = (_a = pickedVariation == null ? void 0 : pickedVariation.pricingTiers) == null ? void 0 : _a.filter((tier) => item.quantity >= tier.minQuantity)) != null ? _b : [];
|
|
574
|
+
const matchingPricingTier = eligiblePricingTiers.length > 0 ? eligiblePricingTiers[eligiblePricingTiers.length - 1] : null;
|
|
575
|
+
price = (_f = (_e = (_c = matchingPricingTier == null ? void 0 : matchingPricingTier.price[currency]) != null ? _c : pickedVariation == null ? void 0 : pickedVariation.price[currency]) != null ? _e : (_d = product == null ? void 0 : product.defaultVariation) == null ? void 0 : _d.price[currency]) != null ? _f : 0;
|
|
564
576
|
} else {
|
|
565
577
|
const bundle = storefront.storefront.value.bundles.find((b) => b.id === item.bundleId);
|
|
566
578
|
const variations = (bundle == null ? void 0 : bundle.variations) || [];
|
|
567
579
|
const pickedVariation = variations.find((v) => v.id === item.variationId);
|
|
568
|
-
price = (
|
|
580
|
+
price = (_i = (_h = pickedVariation == null ? void 0 : pickedVariation.price[currency]) != null ? _h : (_g = bundle == null ? void 0 : bundle.defaultVariation) == null ? void 0 : _g.price[currency]) != null ? _i : 0;
|
|
569
581
|
}
|
|
570
582
|
return agg + price * item.quantity;
|
|
571
583
|
}, 0);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.135",
|
|
5
5
|
"description": "Package to let you build vue.js storefronts with Moonbase.sh as payment and delivery provider",
|
|
6
6
|
"author": "Tobias Lønnerød Madsen <m@dsen.tv>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@vue/devtools-api": "^6.6.3",
|
|
20
20
|
"uuid": "^9.0.1",
|
|
21
21
|
"zod": "^3.23.8",
|
|
22
|
-
"@moonbase.sh/storefront-api": "0.2.
|
|
22
|
+
"@moonbase.sh/storefront-api": "0.2.135"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/uuid": "^9.0.8",
|