subos-frontend 1.0.104 → 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 +140 -133
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -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/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
|
|
@@ -638,18 +614,46 @@ var getGracePeriodInfo = (subscription) => {
|
|
|
638
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.`
|
|
639
615
|
};
|
|
640
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
|
+
};
|
|
641
645
|
|
|
642
646
|
// src/hooks/usePlans.ts
|
|
643
647
|
var usePlans = () => {
|
|
644
648
|
const { currency } = useCurrency();
|
|
645
|
-
const [plans, setPlans] =
|
|
646
|
-
const [filteredPlans, setFilteredPlans] =
|
|
647
|
-
const [selectedPlan, setSelectedPlan] =
|
|
648
|
-
const [tierFilter, setTierFilter] =
|
|
649
|
-
const [billingCycle, setBillingCycle] =
|
|
650
|
-
const [loading, setLoading] =
|
|
651
|
-
const [error, setError] =
|
|
652
|
-
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 () => {
|
|
653
657
|
if (loading) return;
|
|
654
658
|
setLoading(true);
|
|
655
659
|
setError(null);
|
|
@@ -671,7 +675,7 @@ var usePlans = () => {
|
|
|
671
675
|
setLoading(false);
|
|
672
676
|
}
|
|
673
677
|
}, [loading]);
|
|
674
|
-
|
|
678
|
+
React11.useEffect(() => {
|
|
675
679
|
if (plans.length > 0 && tierFilter === "all") {
|
|
676
680
|
const uniqueUnits = getUniqueCandidateUnits(plans);
|
|
677
681
|
if (uniqueUnits.length > 0) {
|
|
@@ -679,17 +683,17 @@ var usePlans = () => {
|
|
|
679
683
|
}
|
|
680
684
|
}
|
|
681
685
|
}, [plans, tierFilter]);
|
|
682
|
-
|
|
686
|
+
React11.useEffect(() => {
|
|
683
687
|
let filtered = [...plans];
|
|
684
688
|
filtered = filterPlansByBillingCycle(filtered, billingCycle);
|
|
685
689
|
filtered = filterPlansByTier(filtered, tierFilter);
|
|
686
690
|
const sorted = sortPlansForDisplay(filtered);
|
|
687
691
|
setFilteredPlans(sorted);
|
|
688
692
|
}, [plans, tierFilter, billingCycle]);
|
|
689
|
-
const handlePlanSelect =
|
|
693
|
+
const handlePlanSelect = React11.useCallback((plan) => {
|
|
690
694
|
setSelectedPlan(plan);
|
|
691
695
|
}, []);
|
|
692
|
-
const handleUpgrade =
|
|
696
|
+
const handleUpgrade = React11.useCallback(async (externalId, options) => {
|
|
693
697
|
var _a;
|
|
694
698
|
if (!selectedPlan) return;
|
|
695
699
|
try {
|
|
@@ -711,14 +715,14 @@ var usePlans = () => {
|
|
|
711
715
|
alert("An error occurred. Please try again.");
|
|
712
716
|
}
|
|
713
717
|
}, [selectedPlan, currency]);
|
|
714
|
-
const clearPlans =
|
|
718
|
+
const clearPlans = React11.useCallback(() => {
|
|
715
719
|
setPlans([]);
|
|
716
720
|
setFilteredPlans([]);
|
|
717
721
|
setSelectedPlan(null);
|
|
718
722
|
setError(null);
|
|
719
723
|
setTierFilter("all");
|
|
720
724
|
}, []);
|
|
721
|
-
const clearSelectedPlan2 =
|
|
725
|
+
const clearSelectedPlan2 = React11.useCallback(() => {
|
|
722
726
|
setSelectedPlan(null);
|
|
723
727
|
}, []);
|
|
724
728
|
const dropdownOptions = getDropdownOptions(plans);
|
|
@@ -804,18 +808,18 @@ var useTransactions = ({
|
|
|
804
808
|
initialFilters = {},
|
|
805
809
|
autoFetch = false
|
|
806
810
|
}) => {
|
|
807
|
-
const [transactions, setTransactions] =
|
|
808
|
-
const [allTransactions, setAllTransactions] =
|
|
809
|
-
const [loading, setLoading] =
|
|
810
|
-
const [error, setError] =
|
|
811
|
-
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({
|
|
812
816
|
...DEFAULT_FILTERS,
|
|
813
817
|
...initialFilters
|
|
814
818
|
});
|
|
815
|
-
const [meta, setMeta] =
|
|
816
|
-
const [isBackendPaginated, setIsBackendPaginated] =
|
|
817
|
-
const hasAutoFetchedRef =
|
|
818
|
-
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 () => {
|
|
819
823
|
if (!externalId) return;
|
|
820
824
|
setLoading(true);
|
|
821
825
|
setError(null);
|
|
@@ -854,7 +858,7 @@ var useTransactions = ({
|
|
|
854
858
|
setLoading(false);
|
|
855
859
|
}
|
|
856
860
|
}, [externalId, filters]);
|
|
857
|
-
const updateFilters =
|
|
861
|
+
const updateFilters = React11.useCallback((newFilters) => {
|
|
858
862
|
setFilters((prev) => ({
|
|
859
863
|
...prev,
|
|
860
864
|
...newFilters,
|
|
@@ -862,7 +866,7 @@ var useTransactions = ({
|
|
|
862
866
|
page: newFilters.page !== void 0 ? newFilters.page : 1
|
|
863
867
|
}));
|
|
864
868
|
}, []);
|
|
865
|
-
|
|
869
|
+
React11.useEffect(() => {
|
|
866
870
|
if (!isBackendPaginated && allTransactions.length > 0) {
|
|
867
871
|
const filteredTransactions = applyFrontendFilters(allTransactions, filters);
|
|
868
872
|
const paginatedResult = applyFrontendPagination(filteredTransactions, filters);
|
|
@@ -870,19 +874,19 @@ var useTransactions = ({
|
|
|
870
874
|
setMeta(paginatedResult.meta);
|
|
871
875
|
}
|
|
872
876
|
}, [filters, allTransactions, isBackendPaginated]);
|
|
873
|
-
const clearFilters =
|
|
877
|
+
const clearFilters = React11.useCallback(() => {
|
|
874
878
|
setFilters(DEFAULT_FILTERS);
|
|
875
879
|
}, []);
|
|
876
|
-
const refetch =
|
|
880
|
+
const refetch = React11.useCallback(async () => {
|
|
877
881
|
await fetchTransactions();
|
|
878
882
|
}, [fetchTransactions]);
|
|
879
|
-
|
|
883
|
+
React11.useEffect(() => {
|
|
880
884
|
if (autoFetch && externalId && !hasAutoFetchedRef.current) {
|
|
881
885
|
hasAutoFetchedRef.current = true;
|
|
882
886
|
fetchTransactions();
|
|
883
887
|
}
|
|
884
888
|
}, [autoFetch, externalId, fetchTransactions]);
|
|
885
|
-
|
|
889
|
+
React11.useEffect(() => {
|
|
886
890
|
if (!autoFetch) return;
|
|
887
891
|
const hasNonPaginationFilters = filters.startDate !== void 0 || filters.endDate !== void 0 || filters.status !== void 0;
|
|
888
892
|
const shouldFetch = isBackendPaginated || allTransactions.length === 0 && hasNonPaginationFilters;
|
|
@@ -909,10 +913,10 @@ var usePagination = ({
|
|
|
909
913
|
initialPage = 1,
|
|
910
914
|
initialLimit = 10
|
|
911
915
|
} = {}) => {
|
|
912
|
-
const [currentPage, setCurrentPage] =
|
|
913
|
-
const [limit, setLimitState] =
|
|
914
|
-
const [meta, setMeta] =
|
|
915
|
-
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) => {
|
|
916
920
|
if (meta) {
|
|
917
921
|
const validPage = Math.max(1, Math.min(page, meta.totalPages));
|
|
918
922
|
setCurrentPage(validPage);
|
|
@@ -920,29 +924,29 @@ var usePagination = ({
|
|
|
920
924
|
setCurrentPage(Math.max(1, page));
|
|
921
925
|
}
|
|
922
926
|
}, [meta]);
|
|
923
|
-
const goToNextPage =
|
|
927
|
+
const goToNextPage = React11.useCallback(() => {
|
|
924
928
|
if (meta && meta.hasNextPage) {
|
|
925
929
|
setCurrentPage((prev) => prev + 1);
|
|
926
930
|
}
|
|
927
931
|
}, [meta]);
|
|
928
|
-
const goToPreviousPage =
|
|
932
|
+
const goToPreviousPage = React11.useCallback(() => {
|
|
929
933
|
if (meta && meta.hasPreviousPage) {
|
|
930
934
|
setCurrentPage((prev) => prev - 1);
|
|
931
935
|
}
|
|
932
936
|
}, [meta]);
|
|
933
|
-
const goToFirstPage =
|
|
937
|
+
const goToFirstPage = React11.useCallback(() => {
|
|
934
938
|
setCurrentPage(1);
|
|
935
939
|
}, []);
|
|
936
|
-
const goToLastPage =
|
|
940
|
+
const goToLastPage = React11.useCallback(() => {
|
|
937
941
|
if (meta) {
|
|
938
942
|
setCurrentPage(meta.totalPages);
|
|
939
943
|
}
|
|
940
944
|
}, [meta]);
|
|
941
|
-
const setLimit =
|
|
945
|
+
const setLimit = React11.useCallback((newLimit) => {
|
|
942
946
|
setLimitState(newLimit);
|
|
943
947
|
setCurrentPage(1);
|
|
944
948
|
}, []);
|
|
945
|
-
const reset =
|
|
949
|
+
const reset = React11.useCallback(() => {
|
|
946
950
|
setCurrentPage(initialPage);
|
|
947
951
|
setLimitState(initialLimit);
|
|
948
952
|
setMeta(null);
|
|
@@ -965,9 +969,9 @@ var useCancelSubscription = ({
|
|
|
965
969
|
onSuccess,
|
|
966
970
|
onError
|
|
967
971
|
} = {}) => {
|
|
968
|
-
const [loading, setLoading] =
|
|
969
|
-
const [error, setError] =
|
|
970
|
-
const cancelSubscription =
|
|
972
|
+
const [loading, setLoading] = React11.useState(false);
|
|
973
|
+
const [error, setError] = React11.useState(null);
|
|
974
|
+
const cancelSubscription = React11.useCallback(async (externalId, options) => {
|
|
971
975
|
if (!externalId) {
|
|
972
976
|
const errorMsg = "External ID is required";
|
|
973
977
|
setError(errorMsg);
|
|
@@ -996,7 +1000,7 @@ var useCancelSubscription = ({
|
|
|
996
1000
|
setLoading(false);
|
|
997
1001
|
}
|
|
998
1002
|
}, [onSuccess, onError]);
|
|
999
|
-
const reset =
|
|
1003
|
+
const reset = React11.useCallback(() => {
|
|
1000
1004
|
setLoading(false);
|
|
1001
1005
|
setError(null);
|
|
1002
1006
|
}, []);
|
|
@@ -1012,9 +1016,9 @@ var useCustomerPortal = ({
|
|
|
1012
1016
|
onError,
|
|
1013
1017
|
returnPath = "/dashboard"
|
|
1014
1018
|
} = {}) => {
|
|
1015
|
-
const [loading, setLoading] =
|
|
1016
|
-
const [error, setError] =
|
|
1017
|
-
const openCustomerPortal =
|
|
1019
|
+
const [loading, setLoading] = React11.useState(false);
|
|
1020
|
+
const [error, setError] = React11.useState(null);
|
|
1021
|
+
const openCustomerPortal = React11.useCallback(async (externalId) => {
|
|
1018
1022
|
var _a;
|
|
1019
1023
|
if (!externalId) {
|
|
1020
1024
|
const errorMsg = "External ID is required";
|
|
@@ -1051,7 +1055,7 @@ var useCustomerPortal = ({
|
|
|
1051
1055
|
setLoading(false);
|
|
1052
1056
|
}
|
|
1053
1057
|
}, [onSuccess, onError, returnPath]);
|
|
1054
|
-
const reset =
|
|
1058
|
+
const reset = React11.useCallback(() => {
|
|
1055
1059
|
setLoading(false);
|
|
1056
1060
|
setError(null);
|
|
1057
1061
|
}, []);
|
|
@@ -1062,13 +1066,13 @@ var useCustomerPortal = ({
|
|
|
1062
1066
|
reset
|
|
1063
1067
|
};
|
|
1064
1068
|
};
|
|
1065
|
-
var NavigationContext =
|
|
1069
|
+
var NavigationContext = React11.createContext(void 0);
|
|
1066
1070
|
var NavigationProvider = ({
|
|
1067
1071
|
children,
|
|
1068
1072
|
initialPage = "dashboard"
|
|
1069
1073
|
}) => {
|
|
1070
|
-
const [currentPage, setCurrentPage] =
|
|
1071
|
-
const [history, setHistory] =
|
|
1074
|
+
const [currentPage, setCurrentPage] = React11.useState(initialPage);
|
|
1075
|
+
const [history, setHistory] = React11.useState([initialPage]);
|
|
1072
1076
|
const navigateTo = (page) => {
|
|
1073
1077
|
setCurrentPage(page);
|
|
1074
1078
|
setHistory((prev) => [...prev, page]);
|
|
@@ -1085,7 +1089,7 @@ var NavigationProvider = ({
|
|
|
1085
1089
|
return /* @__PURE__ */ jsxRuntime.jsx(NavigationContext.Provider, { value: { currentPage, navigateTo, goBack }, children });
|
|
1086
1090
|
};
|
|
1087
1091
|
var useNavigation = () => {
|
|
1088
|
-
const context =
|
|
1092
|
+
const context = React11.useContext(NavigationContext);
|
|
1089
1093
|
if (!context) {
|
|
1090
1094
|
throw new Error("useNavigation must be used within NavigationProvider");
|
|
1091
1095
|
}
|
|
@@ -1169,8 +1173,8 @@ var TierFilterDropdown = ({
|
|
|
1169
1173
|
selectedValue,
|
|
1170
1174
|
onSelect
|
|
1171
1175
|
}) => {
|
|
1172
|
-
const dropdownRef =
|
|
1173
|
-
|
|
1176
|
+
const dropdownRef = React11.useRef(null);
|
|
1177
|
+
React11.useEffect(() => {
|
|
1174
1178
|
const handleClickOutside = (event) => {
|
|
1175
1179
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
1176
1180
|
if (isOpen) {
|
|
@@ -1550,7 +1554,7 @@ var PlanSelector = ({
|
|
|
1550
1554
|
activePlanCode,
|
|
1551
1555
|
nextMembershipPlanId
|
|
1552
1556
|
}) => {
|
|
1553
|
-
const [isDropdownOpen, setIsDropdownOpen] =
|
|
1557
|
+
const [isDropdownOpen, setIsDropdownOpen] = React11.useState(false);
|
|
1554
1558
|
const handleDropdownToggle = () => {
|
|
1555
1559
|
setIsDropdownOpen(!isDropdownOpen);
|
|
1556
1560
|
};
|
|
@@ -1920,7 +1924,7 @@ var Layout = ({ children, hideHeader = false, hideFooter = false }) => {
|
|
|
1920
1924
|
] });
|
|
1921
1925
|
};
|
|
1922
1926
|
var usePaymentParams = () => {
|
|
1923
|
-
return
|
|
1927
|
+
return React11.useMemo(() => {
|
|
1924
1928
|
const params = new URLSearchParams(window.location.search);
|
|
1925
1929
|
return {
|
|
1926
1930
|
gateway: params.get("gateway") || void 0,
|
|
@@ -1951,7 +1955,7 @@ var PaymentSuccessPage = ({
|
|
|
1951
1955
|
initialFilters: { page: 1, limit: 100 },
|
|
1952
1956
|
autoFetch: !!externalId
|
|
1953
1957
|
});
|
|
1954
|
-
const invoiceDownloadUrl =
|
|
1958
|
+
const invoiceDownloadUrl = React11.useMemo(() => {
|
|
1955
1959
|
if (propInvoiceDownloadUrl) return propInvoiceDownloadUrl;
|
|
1956
1960
|
if (!transactions || transactions.length === 0) return void 0;
|
|
1957
1961
|
const withOrder = transactions.filter((t) => typeof t.order === "number");
|
|
@@ -2465,7 +2469,7 @@ var TransactionPagination = ({
|
|
|
2465
2469
|
children: "Previous"
|
|
2466
2470
|
}
|
|
2467
2471
|
),
|
|
2468
|
-
/* @__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(
|
|
2469
2473
|
"button",
|
|
2470
2474
|
{
|
|
2471
2475
|
onClick: () => onPageChange(page),
|
|
@@ -2511,7 +2515,7 @@ var TransactionModal = ({
|
|
|
2511
2515
|
autoFetch: true
|
|
2512
2516
|
// Enable auto-fetch so it works when modal opens
|
|
2513
2517
|
});
|
|
2514
|
-
|
|
2518
|
+
React11.useEffect(() => {
|
|
2515
2519
|
if (isOpen && externalId) {
|
|
2516
2520
|
fetchTransactions();
|
|
2517
2521
|
}
|
|
@@ -3061,9 +3065,11 @@ var GracePeriodNotification = ({
|
|
|
3061
3065
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
|
|
3062
3066
|
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-bold text-orange-900 mb-1", children: "Grace Period Active" }),
|
|
3063
3067
|
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-orange-800", children: [
|
|
3064
|
-
"Your
|
|
3068
|
+
"Your ",
|
|
3069
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-bold", children: "7-day" }),
|
|
3070
|
+
" grace period started on",
|
|
3065
3071
|
" ",
|
|
3066
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-
|
|
3072
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-bold", children: startDate ? formatDate(startDate) : "N/A" }),
|
|
3067
3073
|
". You have ",
|
|
3068
3074
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-bold text-orange-900 text-base", children: [
|
|
3069
3075
|
remainingDays,
|
|
@@ -3089,10 +3095,10 @@ var SubscriptionDetails = ({
|
|
|
3089
3095
|
className = "",
|
|
3090
3096
|
loading = false
|
|
3091
3097
|
}) => {
|
|
3092
|
-
const [isTransactionModalOpen, setIsTransactionModalOpen] =
|
|
3093
|
-
const [showCancelConfirmation, setShowCancelConfirmation] =
|
|
3094
|
-
const [localSubscription, setLocalSubscription] =
|
|
3095
|
-
|
|
3098
|
+
const [isTransactionModalOpen, setIsTransactionModalOpen] = React11.useState(false);
|
|
3099
|
+
const [showCancelConfirmation, setShowCancelConfirmation] = React11.useState(false);
|
|
3100
|
+
const [localSubscription, setLocalSubscription] = React11.useState(subscription);
|
|
3101
|
+
React11.useEffect(() => {
|
|
3096
3102
|
setLocalSubscription(subscription);
|
|
3097
3103
|
}, [subscription]);
|
|
3098
3104
|
const { cancelSubscription, loading: cancelLoading } = useCancelSubscription({
|
|
@@ -3222,9 +3228,9 @@ var UpgradeSummary = ({
|
|
|
3222
3228
|
billableMetricCode
|
|
3223
3229
|
}) => {
|
|
3224
3230
|
const { currency } = useCurrency();
|
|
3225
|
-
const [checkoutInfo, setCheckoutInfo] =
|
|
3226
|
-
const [loading, setLoading] =
|
|
3227
|
-
|
|
3231
|
+
const [checkoutInfo, setCheckoutInfo] = React11.useState(null);
|
|
3232
|
+
const [loading, setLoading] = React11.useState(false);
|
|
3233
|
+
React11.useEffect(() => {
|
|
3228
3234
|
const planToDisplay2 = selectedPlan || currentPlan;
|
|
3229
3235
|
if (!planToDisplay2 || !isVisible || Number(planToDisplay2.fixedCost) === 0) {
|
|
3230
3236
|
setCheckoutInfo(null);
|
|
@@ -3390,9 +3396,9 @@ var UpgradeSummary = ({
|
|
|
3390
3396
|
}
|
|
3391
3397
|
) }) });
|
|
3392
3398
|
};
|
|
3393
|
-
var SubOSThemeContext =
|
|
3399
|
+
var SubOSThemeContext = React11.createContext(void 0);
|
|
3394
3400
|
var useSubOSTheme = () => {
|
|
3395
|
-
const context =
|
|
3401
|
+
const context = React11.useContext(SubOSThemeContext);
|
|
3396
3402
|
if (!context) {
|
|
3397
3403
|
throw new Error("useSubOSTheme must be used within a SubOSThemeProvider");
|
|
3398
3404
|
}
|
|
@@ -3403,8 +3409,8 @@ var SubOSThemeProvider = ({
|
|
|
3403
3409
|
theme = {},
|
|
3404
3410
|
className = ""
|
|
3405
3411
|
}) => {
|
|
3406
|
-
const [currentTheme, setCurrentTheme] =
|
|
3407
|
-
const cssVariables =
|
|
3412
|
+
const [currentTheme, setCurrentTheme] = React11__default.default.useState(theme);
|
|
3413
|
+
const cssVariables = React11__default.default.useMemo(() => {
|
|
3408
3414
|
const vars = {};
|
|
3409
3415
|
if (currentTheme.primaryColors) {
|
|
3410
3416
|
Object.entries(currentTheme.primaryColors).forEach(([key, value]) => {
|
|
@@ -3453,7 +3459,7 @@ var SubOSThemeProvider = ({
|
|
|
3453
3459
|
if (currentTheme.shadowCardHover) vars["--subos-shadow-card-hover"] = currentTheme.shadowCardHover;
|
|
3454
3460
|
return vars;
|
|
3455
3461
|
}, [currentTheme]);
|
|
3456
|
-
const contextValue =
|
|
3462
|
+
const contextValue = React11__default.default.useMemo(() => ({
|
|
3457
3463
|
theme: currentTheme,
|
|
3458
3464
|
setTheme: setCurrentTheme
|
|
3459
3465
|
}), [currentTheme]);
|
|
@@ -3468,7 +3474,7 @@ var SubOSThemeProvider = ({
|
|
|
3468
3474
|
};
|
|
3469
3475
|
var useApplyHostTheme = (hostTheme) => {
|
|
3470
3476
|
const { setTheme } = useSubOSTheme();
|
|
3471
|
-
|
|
3477
|
+
React11__default.default.useEffect(() => {
|
|
3472
3478
|
if (hostTheme) {
|
|
3473
3479
|
setTheme(hostTheme);
|
|
3474
3480
|
}
|
|
@@ -3548,7 +3554,7 @@ var Pagination = ({
|
|
|
3548
3554
|
children: "Previous"
|
|
3549
3555
|
}
|
|
3550
3556
|
),
|
|
3551
|
-
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(
|
|
3552
3558
|
"button",
|
|
3553
3559
|
{
|
|
3554
3560
|
onClick: () => onPageChange(page),
|
|
@@ -3576,8 +3582,8 @@ var DashboardPage = ({
|
|
|
3576
3582
|
const subscription = useSubscription();
|
|
3577
3583
|
const plans = usePlans();
|
|
3578
3584
|
const { currency, isLoading: isCurrencyLoading } = useCurrency();
|
|
3579
|
-
const lastLoadedIdRef =
|
|
3580
|
-
|
|
3585
|
+
const lastLoadedIdRef = React11.useRef(null);
|
|
3586
|
+
React11.useEffect(() => {
|
|
3581
3587
|
if (isCurrencyLoading) return;
|
|
3582
3588
|
const cacheKey = `${externalId}-${currency}`;
|
|
3583
3589
|
if (lastLoadedIdRef.current !== cacheKey) {
|
|
@@ -3586,7 +3592,7 @@ var DashboardPage = ({
|
|
|
3586
3592
|
lastLoadedIdRef.current = cacheKey;
|
|
3587
3593
|
}
|
|
3588
3594
|
}, [externalId, currency, isCurrencyLoading]);
|
|
3589
|
-
|
|
3595
|
+
React11.useEffect(() => {
|
|
3590
3596
|
registerClearSelectedPlan(plans.clearSelectedPlan);
|
|
3591
3597
|
return () => {
|
|
3592
3598
|
unregisterClearSelectedPlan();
|
|
@@ -3653,9 +3659,9 @@ var DashboardPage = ({
|
|
|
3653
3659
|
] }) }) });
|
|
3654
3660
|
};
|
|
3655
3661
|
var useProcessPaymentCancel = (params) => {
|
|
3656
|
-
const [loading, setLoading] =
|
|
3657
|
-
const [error, setError] =
|
|
3658
|
-
|
|
3662
|
+
const [loading, setLoading] = React11.useState(true);
|
|
3663
|
+
const [error, setError] = React11.useState(null);
|
|
3664
|
+
React11.useEffect(() => {
|
|
3659
3665
|
const run = async () => {
|
|
3660
3666
|
try {
|
|
3661
3667
|
const qs = new URLSearchParams({
|
|
@@ -3762,6 +3768,7 @@ exports.SubscriptionCancelButton = SubscriptionCancelButton;
|
|
|
3762
3768
|
exports.SubscriptionCancelModal = SubscriptionCancelModal;
|
|
3763
3769
|
exports.SubscriptionDetails = SubscriptionDetails;
|
|
3764
3770
|
exports.SubscriptionInfoGrid = SubscriptionInfoGrid;
|
|
3771
|
+
exports.SubscriptionProvider = SubscriptionProvider;
|
|
3765
3772
|
exports.SubscriptionTransactionButton = SubscriptionTransactionButton;
|
|
3766
3773
|
exports.SubscriptionUsageDisplay = SubscriptionUsageDisplay;
|
|
3767
3774
|
exports.TierFilterDropdown = TierFilterDropdown;
|