subos-frontend 1.0.103 → 1.0.106
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.js +162 -133
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -49
- package/dist/index.mjs.map +1 -1
- package/dist/types/context/SubscriptionContext.d.ts +15 -0
- package/dist/types/context/SubscriptionContext.d.ts.map +1 -0
- package/dist/types/hooks/useSubscription.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/planUtils.d.ts +9 -0
- package/dist/types/utils/planUtils.d.ts.map +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React11 = require('react');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
|
|
6
6
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var React11__default = /*#__PURE__*/_interopDefault(React11);
|
|
10
10
|
|
|
11
11
|
// src/config/envConfig.ts
|
|
12
12
|
function getEnvVar(key, fallback) {
|
|
@@ -237,35 +237,7 @@ var transactionApi = {
|
|
|
237
237
|
},
|
|
238
238
|
getInvoice: (transactionId) => apiRequest(`${ENDPOINTS.TRANSACTIONS}/${transactionId}/invoice`)
|
|
239
239
|
};
|
|
240
|
-
var
|
|
241
|
-
var UpgradeProvider = ({ children }) => {
|
|
242
|
-
const [isUpgradeSummaryVisible, setIsUpgradeSummaryVisible] = React10.useState(false);
|
|
243
|
-
const setUpgradeSummaryVisible = (visible) => {
|
|
244
|
-
setIsUpgradeSummaryVisible(visible);
|
|
245
|
-
};
|
|
246
|
-
const clearUpgradeSelection = () => {
|
|
247
|
-
setIsUpgradeSummaryVisible(false);
|
|
248
|
-
};
|
|
249
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
250
|
-
UpgradeContext.Provider,
|
|
251
|
-
{
|
|
252
|
-
value: {
|
|
253
|
-
isUpgradeSummaryVisible,
|
|
254
|
-
setUpgradeSummaryVisible,
|
|
255
|
-
clearUpgradeSelection
|
|
256
|
-
},
|
|
257
|
-
children
|
|
258
|
-
}
|
|
259
|
-
);
|
|
260
|
-
};
|
|
261
|
-
var useUpgrade = () => {
|
|
262
|
-
const context = React10.useContext(UpgradeContext);
|
|
263
|
-
if (context === void 0) {
|
|
264
|
-
throw new Error("useUpgrade must be used within an UpgradeProvider");
|
|
265
|
-
}
|
|
266
|
-
return context;
|
|
267
|
-
};
|
|
268
|
-
var CurrencyContext = React10.createContext(void 0);
|
|
240
|
+
var CurrencyContext = React11.createContext(void 0);
|
|
269
241
|
|
|
270
242
|
// src/utils/currency.ts
|
|
271
243
|
var CURRENCY_SYMBOLS = {
|
|
@@ -372,11 +344,11 @@ var useCountryAndCurrency = ({
|
|
|
372
344
|
defaultCurrency = "usd",
|
|
373
345
|
skipAutoDetect = false
|
|
374
346
|
} = {}) => {
|
|
375
|
-
const [country, setCountry] =
|
|
376
|
-
const [currency, setCurrencyState] =
|
|
377
|
-
const [isLoading, setIsLoading] =
|
|
378
|
-
const [error, setError] =
|
|
379
|
-
|
|
347
|
+
const [country, setCountry] = React11.useState(null);
|
|
348
|
+
const [currency, setCurrencyState] = React11.useState(defaultCurrency);
|
|
349
|
+
const [isLoading, setIsLoading] = React11.useState(!skipAutoDetect);
|
|
350
|
+
const [error, setError] = React11.useState(null);
|
|
351
|
+
React11.useEffect(() => {
|
|
380
352
|
if (skipAutoDetect) {
|
|
381
353
|
setIsLoading(false);
|
|
382
354
|
return;
|
|
@@ -417,7 +389,7 @@ var useCountryAndCurrency = ({
|
|
|
417
389
|
};
|
|
418
390
|
};
|
|
419
391
|
var useCurrency = () => {
|
|
420
|
-
const context =
|
|
392
|
+
const context = React11.useContext(CurrencyContext);
|
|
421
393
|
if (context === void 0) {
|
|
422
394
|
throw new Error("useCurrency must be used within a CurrencyProvider");
|
|
423
395
|
}
|
|
@@ -436,17 +408,15 @@ var CurrencyProvider = ({
|
|
|
436
408
|
});
|
|
437
409
|
return /* @__PURE__ */ jsxRuntime.jsx(CurrencyContext.Provider, { value: { country, currency, isLoading, error, setCurrency }, children });
|
|
438
410
|
};
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
var useSubscription = () => {
|
|
411
|
+
var SubscriptionContext = React11.createContext(void 0);
|
|
412
|
+
var SubscriptionProvider = ({ children }) => {
|
|
442
413
|
const { currency } = useCurrency();
|
|
443
|
-
const [subscription, setSubscription] =
|
|
444
|
-
const [loading, setLoading] =
|
|
445
|
-
const [error, setError] =
|
|
446
|
-
const fetchSubscription =
|
|
414
|
+
const [subscription, setSubscription] = React11.useState(null);
|
|
415
|
+
const [loading, setLoading] = React11.useState(false);
|
|
416
|
+
const [error, setError] = React11.useState(null);
|
|
417
|
+
const fetchSubscription = React11.useCallback(async (externalId) => {
|
|
447
418
|
if (!externalId || externalId === "undefined" || externalId.trim() === "") {
|
|
448
419
|
setError("Invalid user ID. Please ensure you are properly authenticated.");
|
|
449
|
-
setLoading(false);
|
|
450
420
|
return;
|
|
451
421
|
}
|
|
452
422
|
if (loading) return;
|
|
@@ -468,17 +438,23 @@ var useSubscription = () => {
|
|
|
468
438
|
setLoading(false);
|
|
469
439
|
}
|
|
470
440
|
}, [loading, currency]);
|
|
471
|
-
const clearSubscription =
|
|
441
|
+
const clearSubscription = React11.useCallback(() => {
|
|
472
442
|
setSubscription(null);
|
|
473
443
|
setError(null);
|
|
474
444
|
}, []);
|
|
475
|
-
return {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
}
|
|
445
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SubscriptionContext.Provider, { value: { subscription, loading, error, fetchSubscription, clearSubscription }, children });
|
|
446
|
+
};
|
|
447
|
+
var useSubscriptionContext = () => {
|
|
448
|
+
const context = React11.useContext(SubscriptionContext);
|
|
449
|
+
if (context === void 0) {
|
|
450
|
+
throw new Error("useSubscriptionContext must be used within a SubscriptionProvider");
|
|
451
|
+
}
|
|
452
|
+
return context;
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
// src/hooks/useSubscription.ts
|
|
456
|
+
var useSubscription = () => {
|
|
457
|
+
return useSubscriptionContext();
|
|
482
458
|
};
|
|
483
459
|
|
|
484
460
|
// src/utils/planUtils.ts
|
|
@@ -617,18 +593,67 @@ var formatDate = (dateString, format = "date") => {
|
|
|
617
593
|
day: "numeric"
|
|
618
594
|
}).format(date);
|
|
619
595
|
};
|
|
596
|
+
var getGracePeriodInfo = (subscription) => {
|
|
597
|
+
var _a;
|
|
598
|
+
if (!((_a = subscription == null ? void 0 : subscription.meta) == null ? void 0 : _a.isGracePeriod)) {
|
|
599
|
+
return null;
|
|
600
|
+
}
|
|
601
|
+
const startDate = subscription.meta.gracePeriodStart;
|
|
602
|
+
const endDate = subscription.meta.gracePeriodEnd;
|
|
603
|
+
let remainingDays = subscription.remainingGracePeriodDays ?? 0;
|
|
604
|
+
if (endDate) {
|
|
605
|
+
const end = new Date(endDate).getTime();
|
|
606
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
607
|
+
const diff = end - now;
|
|
608
|
+
remainingDays = Math.max(0, Math.ceil(diff / (1e3 * 60 * 60 * 24)));
|
|
609
|
+
}
|
|
610
|
+
return {
|
|
611
|
+
startDate,
|
|
612
|
+
endDate,
|
|
613
|
+
remainingDays,
|
|
614
|
+
message: `Your 7-day grace period started on ${startDate ? formatDate(startDate) : "N/A"}. You have ${remainingDays} days remaining to update your payment method to continue your subscription without interruption.`
|
|
615
|
+
};
|
|
616
|
+
};
|
|
617
|
+
var UpgradeContext = React11.createContext(void 0);
|
|
618
|
+
var UpgradeProvider = ({ children }) => {
|
|
619
|
+
const [isUpgradeSummaryVisible, setIsUpgradeSummaryVisible] = React11.useState(false);
|
|
620
|
+
const setUpgradeSummaryVisible = (visible) => {
|
|
621
|
+
setIsUpgradeSummaryVisible(visible);
|
|
622
|
+
};
|
|
623
|
+
const clearUpgradeSelection = () => {
|
|
624
|
+
setIsUpgradeSummaryVisible(false);
|
|
625
|
+
};
|
|
626
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
627
|
+
UpgradeContext.Provider,
|
|
628
|
+
{
|
|
629
|
+
value: {
|
|
630
|
+
isUpgradeSummaryVisible,
|
|
631
|
+
setUpgradeSummaryVisible,
|
|
632
|
+
clearUpgradeSelection
|
|
633
|
+
},
|
|
634
|
+
children
|
|
635
|
+
}
|
|
636
|
+
);
|
|
637
|
+
};
|
|
638
|
+
var useUpgrade = () => {
|
|
639
|
+
const context = React11.useContext(UpgradeContext);
|
|
640
|
+
if (context === void 0) {
|
|
641
|
+
throw new Error("useUpgrade must be used within an UpgradeProvider");
|
|
642
|
+
}
|
|
643
|
+
return context;
|
|
644
|
+
};
|
|
620
645
|
|
|
621
646
|
// src/hooks/usePlans.ts
|
|
622
647
|
var usePlans = () => {
|
|
623
648
|
const { currency } = useCurrency();
|
|
624
|
-
const [plans, setPlans] =
|
|
625
|
-
const [filteredPlans, setFilteredPlans] =
|
|
626
|
-
const [selectedPlan, setSelectedPlan] =
|
|
627
|
-
const [tierFilter, setTierFilter] =
|
|
628
|
-
const [billingCycle, setBillingCycle] =
|
|
629
|
-
const [loading, setLoading] =
|
|
630
|
-
const [error, setError] =
|
|
631
|
-
const fetchPlans =
|
|
649
|
+
const [plans, setPlans] = React11.useState([]);
|
|
650
|
+
const [filteredPlans, setFilteredPlans] = React11.useState([]);
|
|
651
|
+
const [selectedPlan, setSelectedPlan] = React11.useState(null);
|
|
652
|
+
const [tierFilter, setTierFilter] = React11.useState("all");
|
|
653
|
+
const [billingCycle, setBillingCycle] = React11.useState("monthly");
|
|
654
|
+
const [loading, setLoading] = React11.useState(false);
|
|
655
|
+
const [error, setError] = React11.useState(null);
|
|
656
|
+
const fetchPlans = React11.useCallback(async () => {
|
|
632
657
|
if (loading) return;
|
|
633
658
|
setLoading(true);
|
|
634
659
|
setError(null);
|
|
@@ -650,7 +675,7 @@ var usePlans = () => {
|
|
|
650
675
|
setLoading(false);
|
|
651
676
|
}
|
|
652
677
|
}, [loading]);
|
|
653
|
-
|
|
678
|
+
React11.useEffect(() => {
|
|
654
679
|
if (plans.length > 0 && tierFilter === "all") {
|
|
655
680
|
const uniqueUnits = getUniqueCandidateUnits(plans);
|
|
656
681
|
if (uniqueUnits.length > 0) {
|
|
@@ -658,17 +683,17 @@ var usePlans = () => {
|
|
|
658
683
|
}
|
|
659
684
|
}
|
|
660
685
|
}, [plans, tierFilter]);
|
|
661
|
-
|
|
686
|
+
React11.useEffect(() => {
|
|
662
687
|
let filtered = [...plans];
|
|
663
688
|
filtered = filterPlansByBillingCycle(filtered, billingCycle);
|
|
664
689
|
filtered = filterPlansByTier(filtered, tierFilter);
|
|
665
690
|
const sorted = sortPlansForDisplay(filtered);
|
|
666
691
|
setFilteredPlans(sorted);
|
|
667
692
|
}, [plans, tierFilter, billingCycle]);
|
|
668
|
-
const handlePlanSelect =
|
|
693
|
+
const handlePlanSelect = React11.useCallback((plan) => {
|
|
669
694
|
setSelectedPlan(plan);
|
|
670
695
|
}, []);
|
|
671
|
-
const handleUpgrade =
|
|
696
|
+
const handleUpgrade = React11.useCallback(async (externalId, options) => {
|
|
672
697
|
var _a;
|
|
673
698
|
if (!selectedPlan) return;
|
|
674
699
|
try {
|
|
@@ -690,14 +715,14 @@ var usePlans = () => {
|
|
|
690
715
|
alert("An error occurred. Please try again.");
|
|
691
716
|
}
|
|
692
717
|
}, [selectedPlan, currency]);
|
|
693
|
-
const clearPlans =
|
|
718
|
+
const clearPlans = React11.useCallback(() => {
|
|
694
719
|
setPlans([]);
|
|
695
720
|
setFilteredPlans([]);
|
|
696
721
|
setSelectedPlan(null);
|
|
697
722
|
setError(null);
|
|
698
723
|
setTierFilter("all");
|
|
699
724
|
}, []);
|
|
700
|
-
const clearSelectedPlan2 =
|
|
725
|
+
const clearSelectedPlan2 = React11.useCallback(() => {
|
|
701
726
|
setSelectedPlan(null);
|
|
702
727
|
}, []);
|
|
703
728
|
const dropdownOptions = getDropdownOptions(plans);
|
|
@@ -783,18 +808,18 @@ var useTransactions = ({
|
|
|
783
808
|
initialFilters = {},
|
|
784
809
|
autoFetch = false
|
|
785
810
|
}) => {
|
|
786
|
-
const [transactions, setTransactions] =
|
|
787
|
-
const [allTransactions, setAllTransactions] =
|
|
788
|
-
const [loading, setLoading] =
|
|
789
|
-
const [error, setError] =
|
|
790
|
-
const [filters, setFilters] =
|
|
811
|
+
const [transactions, setTransactions] = React11.useState([]);
|
|
812
|
+
const [allTransactions, setAllTransactions] = React11.useState([]);
|
|
813
|
+
const [loading, setLoading] = React11.useState(false);
|
|
814
|
+
const [error, setError] = React11.useState(null);
|
|
815
|
+
const [filters, setFilters] = React11.useState({
|
|
791
816
|
...DEFAULT_FILTERS,
|
|
792
817
|
...initialFilters
|
|
793
818
|
});
|
|
794
|
-
const [meta, setMeta] =
|
|
795
|
-
const [isBackendPaginated, setIsBackendPaginated] =
|
|
796
|
-
const hasAutoFetchedRef =
|
|
797
|
-
const fetchTransactions =
|
|
819
|
+
const [meta, setMeta] = React11.useState(null);
|
|
820
|
+
const [isBackendPaginated, setIsBackendPaginated] = React11.useState(false);
|
|
821
|
+
const hasAutoFetchedRef = React11.useRef(false);
|
|
822
|
+
const fetchTransactions = React11.useCallback(async () => {
|
|
798
823
|
if (!externalId) return;
|
|
799
824
|
setLoading(true);
|
|
800
825
|
setError(null);
|
|
@@ -833,7 +858,7 @@ var useTransactions = ({
|
|
|
833
858
|
setLoading(false);
|
|
834
859
|
}
|
|
835
860
|
}, [externalId, filters]);
|
|
836
|
-
const updateFilters =
|
|
861
|
+
const updateFilters = React11.useCallback((newFilters) => {
|
|
837
862
|
setFilters((prev) => ({
|
|
838
863
|
...prev,
|
|
839
864
|
...newFilters,
|
|
@@ -841,7 +866,7 @@ var useTransactions = ({
|
|
|
841
866
|
page: newFilters.page !== void 0 ? newFilters.page : 1
|
|
842
867
|
}));
|
|
843
868
|
}, []);
|
|
844
|
-
|
|
869
|
+
React11.useEffect(() => {
|
|
845
870
|
if (!isBackendPaginated && allTransactions.length > 0) {
|
|
846
871
|
const filteredTransactions = applyFrontendFilters(allTransactions, filters);
|
|
847
872
|
const paginatedResult = applyFrontendPagination(filteredTransactions, filters);
|
|
@@ -849,19 +874,19 @@ var useTransactions = ({
|
|
|
849
874
|
setMeta(paginatedResult.meta);
|
|
850
875
|
}
|
|
851
876
|
}, [filters, allTransactions, isBackendPaginated]);
|
|
852
|
-
const clearFilters =
|
|
877
|
+
const clearFilters = React11.useCallback(() => {
|
|
853
878
|
setFilters(DEFAULT_FILTERS);
|
|
854
879
|
}, []);
|
|
855
|
-
const refetch =
|
|
880
|
+
const refetch = React11.useCallback(async () => {
|
|
856
881
|
await fetchTransactions();
|
|
857
882
|
}, [fetchTransactions]);
|
|
858
|
-
|
|
883
|
+
React11.useEffect(() => {
|
|
859
884
|
if (autoFetch && externalId && !hasAutoFetchedRef.current) {
|
|
860
885
|
hasAutoFetchedRef.current = true;
|
|
861
886
|
fetchTransactions();
|
|
862
887
|
}
|
|
863
888
|
}, [autoFetch, externalId, fetchTransactions]);
|
|
864
|
-
|
|
889
|
+
React11.useEffect(() => {
|
|
865
890
|
if (!autoFetch) return;
|
|
866
891
|
const hasNonPaginationFilters = filters.startDate !== void 0 || filters.endDate !== void 0 || filters.status !== void 0;
|
|
867
892
|
const shouldFetch = isBackendPaginated || allTransactions.length === 0 && hasNonPaginationFilters;
|
|
@@ -888,10 +913,10 @@ var usePagination = ({
|
|
|
888
913
|
initialPage = 1,
|
|
889
914
|
initialLimit = 10
|
|
890
915
|
} = {}) => {
|
|
891
|
-
const [currentPage, setCurrentPage] =
|
|
892
|
-
const [limit, setLimitState] =
|
|
893
|
-
const [meta, setMeta] =
|
|
894
|
-
const goToPage =
|
|
916
|
+
const [currentPage, setCurrentPage] = React11.useState(initialPage);
|
|
917
|
+
const [limit, setLimitState] = React11.useState(initialLimit);
|
|
918
|
+
const [meta, setMeta] = React11.useState(null);
|
|
919
|
+
const goToPage = React11.useCallback((page) => {
|
|
895
920
|
if (meta) {
|
|
896
921
|
const validPage = Math.max(1, Math.min(page, meta.totalPages));
|
|
897
922
|
setCurrentPage(validPage);
|
|
@@ -899,29 +924,29 @@ var usePagination = ({
|
|
|
899
924
|
setCurrentPage(Math.max(1, page));
|
|
900
925
|
}
|
|
901
926
|
}, [meta]);
|
|
902
|
-
const goToNextPage =
|
|
927
|
+
const goToNextPage = React11.useCallback(() => {
|
|
903
928
|
if (meta && meta.hasNextPage) {
|
|
904
929
|
setCurrentPage((prev) => prev + 1);
|
|
905
930
|
}
|
|
906
931
|
}, [meta]);
|
|
907
|
-
const goToPreviousPage =
|
|
932
|
+
const goToPreviousPage = React11.useCallback(() => {
|
|
908
933
|
if (meta && meta.hasPreviousPage) {
|
|
909
934
|
setCurrentPage((prev) => prev - 1);
|
|
910
935
|
}
|
|
911
936
|
}, [meta]);
|
|
912
|
-
const goToFirstPage =
|
|
937
|
+
const goToFirstPage = React11.useCallback(() => {
|
|
913
938
|
setCurrentPage(1);
|
|
914
939
|
}, []);
|
|
915
|
-
const goToLastPage =
|
|
940
|
+
const goToLastPage = React11.useCallback(() => {
|
|
916
941
|
if (meta) {
|
|
917
942
|
setCurrentPage(meta.totalPages);
|
|
918
943
|
}
|
|
919
944
|
}, [meta]);
|
|
920
|
-
const setLimit =
|
|
945
|
+
const setLimit = React11.useCallback((newLimit) => {
|
|
921
946
|
setLimitState(newLimit);
|
|
922
947
|
setCurrentPage(1);
|
|
923
948
|
}, []);
|
|
924
|
-
const reset =
|
|
949
|
+
const reset = React11.useCallback(() => {
|
|
925
950
|
setCurrentPage(initialPage);
|
|
926
951
|
setLimitState(initialLimit);
|
|
927
952
|
setMeta(null);
|
|
@@ -944,9 +969,9 @@ var useCancelSubscription = ({
|
|
|
944
969
|
onSuccess,
|
|
945
970
|
onError
|
|
946
971
|
} = {}) => {
|
|
947
|
-
const [loading, setLoading] =
|
|
948
|
-
const [error, setError] =
|
|
949
|
-
const cancelSubscription =
|
|
972
|
+
const [loading, setLoading] = React11.useState(false);
|
|
973
|
+
const [error, setError] = React11.useState(null);
|
|
974
|
+
const cancelSubscription = React11.useCallback(async (externalId, options) => {
|
|
950
975
|
if (!externalId) {
|
|
951
976
|
const errorMsg = "External ID is required";
|
|
952
977
|
setError(errorMsg);
|
|
@@ -975,7 +1000,7 @@ var useCancelSubscription = ({
|
|
|
975
1000
|
setLoading(false);
|
|
976
1001
|
}
|
|
977
1002
|
}, [onSuccess, onError]);
|
|
978
|
-
const reset =
|
|
1003
|
+
const reset = React11.useCallback(() => {
|
|
979
1004
|
setLoading(false);
|
|
980
1005
|
setError(null);
|
|
981
1006
|
}, []);
|
|
@@ -991,9 +1016,9 @@ var useCustomerPortal = ({
|
|
|
991
1016
|
onError,
|
|
992
1017
|
returnPath = "/dashboard"
|
|
993
1018
|
} = {}) => {
|
|
994
|
-
const [loading, setLoading] =
|
|
995
|
-
const [error, setError] =
|
|
996
|
-
const openCustomerPortal =
|
|
1019
|
+
const [loading, setLoading] = React11.useState(false);
|
|
1020
|
+
const [error, setError] = React11.useState(null);
|
|
1021
|
+
const openCustomerPortal = React11.useCallback(async (externalId) => {
|
|
997
1022
|
var _a;
|
|
998
1023
|
if (!externalId) {
|
|
999
1024
|
const errorMsg = "External ID is required";
|
|
@@ -1030,7 +1055,7 @@ var useCustomerPortal = ({
|
|
|
1030
1055
|
setLoading(false);
|
|
1031
1056
|
}
|
|
1032
1057
|
}, [onSuccess, onError, returnPath]);
|
|
1033
|
-
const reset =
|
|
1058
|
+
const reset = React11.useCallback(() => {
|
|
1034
1059
|
setLoading(false);
|
|
1035
1060
|
setError(null);
|
|
1036
1061
|
}, []);
|
|
@@ -1041,13 +1066,13 @@ var useCustomerPortal = ({
|
|
|
1041
1066
|
reset
|
|
1042
1067
|
};
|
|
1043
1068
|
};
|
|
1044
|
-
var NavigationContext =
|
|
1069
|
+
var NavigationContext = React11.createContext(void 0);
|
|
1045
1070
|
var NavigationProvider = ({
|
|
1046
1071
|
children,
|
|
1047
1072
|
initialPage = "dashboard"
|
|
1048
1073
|
}) => {
|
|
1049
|
-
const [currentPage, setCurrentPage] =
|
|
1050
|
-
const [history, setHistory] =
|
|
1074
|
+
const [currentPage, setCurrentPage] = React11.useState(initialPage);
|
|
1075
|
+
const [history, setHistory] = React11.useState([initialPage]);
|
|
1051
1076
|
const navigateTo = (page) => {
|
|
1052
1077
|
setCurrentPage(page);
|
|
1053
1078
|
setHistory((prev) => [...prev, page]);
|
|
@@ -1064,7 +1089,7 @@ var NavigationProvider = ({
|
|
|
1064
1089
|
return /* @__PURE__ */ jsxRuntime.jsx(NavigationContext.Provider, { value: { currentPage, navigateTo, goBack }, children });
|
|
1065
1090
|
};
|
|
1066
1091
|
var useNavigation = () => {
|
|
1067
|
-
const context =
|
|
1092
|
+
const context = React11.useContext(NavigationContext);
|
|
1068
1093
|
if (!context) {
|
|
1069
1094
|
throw new Error("useNavigation must be used within NavigationProvider");
|
|
1070
1095
|
}
|
|
@@ -1148,8 +1173,8 @@ var TierFilterDropdown = ({
|
|
|
1148
1173
|
selectedValue,
|
|
1149
1174
|
onSelect
|
|
1150
1175
|
}) => {
|
|
1151
|
-
const dropdownRef =
|
|
1152
|
-
|
|
1176
|
+
const dropdownRef = React11.useRef(null);
|
|
1177
|
+
React11.useEffect(() => {
|
|
1153
1178
|
const handleClickOutside = (event) => {
|
|
1154
1179
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
1155
1180
|
if (isOpen) {
|
|
@@ -1529,7 +1554,7 @@ var PlanSelector = ({
|
|
|
1529
1554
|
activePlanCode,
|
|
1530
1555
|
nextMembershipPlanId
|
|
1531
1556
|
}) => {
|
|
1532
|
-
const [isDropdownOpen, setIsDropdownOpen] =
|
|
1557
|
+
const [isDropdownOpen, setIsDropdownOpen] = React11.useState(false);
|
|
1533
1558
|
const handleDropdownToggle = () => {
|
|
1534
1559
|
setIsDropdownOpen(!isDropdownOpen);
|
|
1535
1560
|
};
|
|
@@ -1899,7 +1924,7 @@ var Layout = ({ children, hideHeader = false, hideFooter = false }) => {
|
|
|
1899
1924
|
] });
|
|
1900
1925
|
};
|
|
1901
1926
|
var usePaymentParams = () => {
|
|
1902
|
-
return
|
|
1927
|
+
return React11.useMemo(() => {
|
|
1903
1928
|
const params = new URLSearchParams(window.location.search);
|
|
1904
1929
|
return {
|
|
1905
1930
|
gateway: params.get("gateway") || void 0,
|
|
@@ -1930,7 +1955,7 @@ var PaymentSuccessPage = ({
|
|
|
1930
1955
|
initialFilters: { page: 1, limit: 100 },
|
|
1931
1956
|
autoFetch: !!externalId
|
|
1932
1957
|
});
|
|
1933
|
-
const invoiceDownloadUrl =
|
|
1958
|
+
const invoiceDownloadUrl = React11.useMemo(() => {
|
|
1934
1959
|
if (propInvoiceDownloadUrl) return propInvoiceDownloadUrl;
|
|
1935
1960
|
if (!transactions || transactions.length === 0) return void 0;
|
|
1936
1961
|
const withOrder = transactions.filter((t) => typeof t.order === "number");
|
|
@@ -2444,7 +2469,7 @@ var TransactionPagination = ({
|
|
|
2444
2469
|
children: "Previous"
|
|
2445
2470
|
}
|
|
2446
2471
|
),
|
|
2447
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center space-x-1", children: getVisiblePages().map((page, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2472
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center space-x-1", children: getVisiblePages().map((page, index) => /* @__PURE__ */ jsxRuntime.jsx(React11__default.default.Fragment, { children: page === "..." ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "px-3 py-2 text-sm text-gray-500", children: "..." }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2448
2473
|
"button",
|
|
2449
2474
|
{
|
|
2450
2475
|
onClick: () => onPageChange(page),
|
|
@@ -2490,7 +2515,7 @@ var TransactionModal = ({
|
|
|
2490
2515
|
autoFetch: true
|
|
2491
2516
|
// Enable auto-fetch so it works when modal opens
|
|
2492
2517
|
});
|
|
2493
|
-
|
|
2518
|
+
React11.useEffect(() => {
|
|
2494
2519
|
if (isOpen && externalId) {
|
|
2495
2520
|
fetchTransactions();
|
|
2496
2521
|
}
|
|
@@ -3040,9 +3065,11 @@ var GracePeriodNotification = ({
|
|
|
3040
3065
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
|
|
3041
3066
|
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-bold text-orange-900 mb-1", children: "Grace Period Active" }),
|
|
3042
3067
|
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-orange-800", children: [
|
|
3043
|
-
"Your
|
|
3068
|
+
"Your ",
|
|
3069
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-bold", children: "7-day" }),
|
|
3070
|
+
" grace period started on",
|
|
3044
3071
|
" ",
|
|
3045
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-
|
|
3072
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-bold", children: startDate ? formatDate(startDate) : "N/A" }),
|
|
3046
3073
|
". You have ",
|
|
3047
3074
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-bold text-orange-900 text-base", children: [
|
|
3048
3075
|
remainingDays,
|
|
@@ -3068,10 +3095,10 @@ var SubscriptionDetails = ({
|
|
|
3068
3095
|
className = "",
|
|
3069
3096
|
loading = false
|
|
3070
3097
|
}) => {
|
|
3071
|
-
const [isTransactionModalOpen, setIsTransactionModalOpen] =
|
|
3072
|
-
const [showCancelConfirmation, setShowCancelConfirmation] =
|
|
3073
|
-
const [localSubscription, setLocalSubscription] =
|
|
3074
|
-
|
|
3098
|
+
const [isTransactionModalOpen, setIsTransactionModalOpen] = React11.useState(false);
|
|
3099
|
+
const [showCancelConfirmation, setShowCancelConfirmation] = React11.useState(false);
|
|
3100
|
+
const [localSubscription, setLocalSubscription] = React11.useState(subscription);
|
|
3101
|
+
React11.useEffect(() => {
|
|
3075
3102
|
setLocalSubscription(subscription);
|
|
3076
3103
|
}, [subscription]);
|
|
3077
3104
|
const { cancelSubscription, loading: cancelLoading } = useCancelSubscription({
|
|
@@ -3201,9 +3228,9 @@ var UpgradeSummary = ({
|
|
|
3201
3228
|
billableMetricCode
|
|
3202
3229
|
}) => {
|
|
3203
3230
|
const { currency } = useCurrency();
|
|
3204
|
-
const [checkoutInfo, setCheckoutInfo] =
|
|
3205
|
-
const [loading, setLoading] =
|
|
3206
|
-
|
|
3231
|
+
const [checkoutInfo, setCheckoutInfo] = React11.useState(null);
|
|
3232
|
+
const [loading, setLoading] = React11.useState(false);
|
|
3233
|
+
React11.useEffect(() => {
|
|
3207
3234
|
const planToDisplay2 = selectedPlan || currentPlan;
|
|
3208
3235
|
if (!planToDisplay2 || !isVisible || Number(planToDisplay2.fixedCost) === 0) {
|
|
3209
3236
|
setCheckoutInfo(null);
|
|
@@ -3369,9 +3396,9 @@ var UpgradeSummary = ({
|
|
|
3369
3396
|
}
|
|
3370
3397
|
) }) });
|
|
3371
3398
|
};
|
|
3372
|
-
var SubOSThemeContext =
|
|
3399
|
+
var SubOSThemeContext = React11.createContext(void 0);
|
|
3373
3400
|
var useSubOSTheme = () => {
|
|
3374
|
-
const context =
|
|
3401
|
+
const context = React11.useContext(SubOSThemeContext);
|
|
3375
3402
|
if (!context) {
|
|
3376
3403
|
throw new Error("useSubOSTheme must be used within a SubOSThemeProvider");
|
|
3377
3404
|
}
|
|
@@ -3382,8 +3409,8 @@ var SubOSThemeProvider = ({
|
|
|
3382
3409
|
theme = {},
|
|
3383
3410
|
className = ""
|
|
3384
3411
|
}) => {
|
|
3385
|
-
const [currentTheme, setCurrentTheme] =
|
|
3386
|
-
const cssVariables =
|
|
3412
|
+
const [currentTheme, setCurrentTheme] = React11__default.default.useState(theme);
|
|
3413
|
+
const cssVariables = React11__default.default.useMemo(() => {
|
|
3387
3414
|
const vars = {};
|
|
3388
3415
|
if (currentTheme.primaryColors) {
|
|
3389
3416
|
Object.entries(currentTheme.primaryColors).forEach(([key, value]) => {
|
|
@@ -3432,7 +3459,7 @@ var SubOSThemeProvider = ({
|
|
|
3432
3459
|
if (currentTheme.shadowCardHover) vars["--subos-shadow-card-hover"] = currentTheme.shadowCardHover;
|
|
3433
3460
|
return vars;
|
|
3434
3461
|
}, [currentTheme]);
|
|
3435
|
-
const contextValue =
|
|
3462
|
+
const contextValue = React11__default.default.useMemo(() => ({
|
|
3436
3463
|
theme: currentTheme,
|
|
3437
3464
|
setTheme: setCurrentTheme
|
|
3438
3465
|
}), [currentTheme]);
|
|
@@ -3447,7 +3474,7 @@ var SubOSThemeProvider = ({
|
|
|
3447
3474
|
};
|
|
3448
3475
|
var useApplyHostTheme = (hostTheme) => {
|
|
3449
3476
|
const { setTheme } = useSubOSTheme();
|
|
3450
|
-
|
|
3477
|
+
React11__default.default.useEffect(() => {
|
|
3451
3478
|
if (hostTheme) {
|
|
3452
3479
|
setTheme(hostTheme);
|
|
3453
3480
|
}
|
|
@@ -3527,7 +3554,7 @@ var Pagination = ({
|
|
|
3527
3554
|
children: "Previous"
|
|
3528
3555
|
}
|
|
3529
3556
|
),
|
|
3530
|
-
pageNumbers.map((page, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3557
|
+
pageNumbers.map((page, index) => /* @__PURE__ */ jsxRuntime.jsx(React11__default.default.Fragment, { children: page === "..." ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "px-3 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300", children: "..." }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3531
3558
|
"button",
|
|
3532
3559
|
{
|
|
3533
3560
|
onClick: () => onPageChange(page),
|
|
@@ -3555,8 +3582,8 @@ var DashboardPage = ({
|
|
|
3555
3582
|
const subscription = useSubscription();
|
|
3556
3583
|
const plans = usePlans();
|
|
3557
3584
|
const { currency, isLoading: isCurrencyLoading } = useCurrency();
|
|
3558
|
-
const lastLoadedIdRef =
|
|
3559
|
-
|
|
3585
|
+
const lastLoadedIdRef = React11.useRef(null);
|
|
3586
|
+
React11.useEffect(() => {
|
|
3560
3587
|
if (isCurrencyLoading) return;
|
|
3561
3588
|
const cacheKey = `${externalId}-${currency}`;
|
|
3562
3589
|
if (lastLoadedIdRef.current !== cacheKey) {
|
|
@@ -3565,7 +3592,7 @@ var DashboardPage = ({
|
|
|
3565
3592
|
lastLoadedIdRef.current = cacheKey;
|
|
3566
3593
|
}
|
|
3567
3594
|
}, [externalId, currency, isCurrencyLoading]);
|
|
3568
|
-
|
|
3595
|
+
React11.useEffect(() => {
|
|
3569
3596
|
registerClearSelectedPlan(plans.clearSelectedPlan);
|
|
3570
3597
|
return () => {
|
|
3571
3598
|
unregisterClearSelectedPlan();
|
|
@@ -3632,9 +3659,9 @@ var DashboardPage = ({
|
|
|
3632
3659
|
] }) }) });
|
|
3633
3660
|
};
|
|
3634
3661
|
var useProcessPaymentCancel = (params) => {
|
|
3635
|
-
const [loading, setLoading] =
|
|
3636
|
-
const [error, setError] =
|
|
3637
|
-
|
|
3662
|
+
const [loading, setLoading] = React11.useState(true);
|
|
3663
|
+
const [error, setError] = React11.useState(null);
|
|
3664
|
+
React11.useEffect(() => {
|
|
3638
3665
|
const run = async () => {
|
|
3639
3666
|
try {
|
|
3640
3667
|
const qs = new URLSearchParams({
|
|
@@ -3741,6 +3768,7 @@ exports.SubscriptionCancelButton = SubscriptionCancelButton;
|
|
|
3741
3768
|
exports.SubscriptionCancelModal = SubscriptionCancelModal;
|
|
3742
3769
|
exports.SubscriptionDetails = SubscriptionDetails;
|
|
3743
3770
|
exports.SubscriptionInfoGrid = SubscriptionInfoGrid;
|
|
3771
|
+
exports.SubscriptionProvider = SubscriptionProvider;
|
|
3744
3772
|
exports.SubscriptionTransactionButton = SubscriptionTransactionButton;
|
|
3745
3773
|
exports.SubscriptionUsageDisplay = SubscriptionUsageDisplay;
|
|
3746
3774
|
exports.TierFilterDropdown = TierFilterDropdown;
|
|
@@ -3768,6 +3796,7 @@ exports.getApiBaseUrl = getApiBaseUrl;
|
|
|
3768
3796
|
exports.getCandidateUnits = getCandidateUnits;
|
|
3769
3797
|
exports.getCurrentSelectionText = getCurrentSelectionText;
|
|
3770
3798
|
exports.getDropdownOptions = getDropdownOptions;
|
|
3799
|
+
exports.getGracePeriodInfo = getGracePeriodInfo;
|
|
3771
3800
|
exports.getPlanDescription = getPlanDescription;
|
|
3772
3801
|
exports.getPlanFeatures = getPlanFeatures;
|
|
3773
3802
|
exports.getProjectId = getProjectId;
|