subos-frontend 1.0.93 → 1.0.95
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 +135 -107
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -22
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/payments/PaymentCancelView.d.ts.map +1 -1
- package/dist/types/context/CurrencyContext.d.ts.map +1 -1
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/index.d.ts.map +1 -1
- package/dist/types/hooks/useCountryAndCurrency.d.ts +14 -0
- package/dist/types/hooks/useCountryAndCurrency.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React10 = 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 React10__default = /*#__PURE__*/_interopDefault(React10);
|
|
10
10
|
|
|
11
11
|
// src/config/envConfig.ts
|
|
12
12
|
function getEnvVar(key, fallback) {
|
|
@@ -232,10 +232,10 @@ var transactionApi = {
|
|
|
232
232
|
getInvoice: (transactionId) => apiRequest(`${ENDPOINTS.TRANSACTIONS}/${transactionId}/invoice`)
|
|
233
233
|
};
|
|
234
234
|
var useSubscription = () => {
|
|
235
|
-
const [subscription, setSubscription] =
|
|
236
|
-
const [loading, setLoading] =
|
|
237
|
-
const [error, setError] =
|
|
238
|
-
const fetchSubscription =
|
|
235
|
+
const [subscription, setSubscription] = React10.useState(null);
|
|
236
|
+
const [loading, setLoading] = React10.useState(false);
|
|
237
|
+
const [error, setError] = React10.useState(null);
|
|
238
|
+
const fetchSubscription = React10.useCallback(async (externalId) => {
|
|
239
239
|
if (!externalId || externalId === "undefined" || externalId.trim() === "") {
|
|
240
240
|
setError("Invalid user ID. Please ensure you are properly authenticated.");
|
|
241
241
|
setLoading(false);
|
|
@@ -260,7 +260,7 @@ var useSubscription = () => {
|
|
|
260
260
|
setLoading(false);
|
|
261
261
|
}
|
|
262
262
|
}, [loading]);
|
|
263
|
-
const clearSubscription =
|
|
263
|
+
const clearSubscription = React10.useCallback(() => {
|
|
264
264
|
setSubscription(null);
|
|
265
265
|
setError(null);
|
|
266
266
|
}, []);
|
|
@@ -409,9 +409,9 @@ var formatDate = (dateString, format = "date") => {
|
|
|
409
409
|
day: "numeric"
|
|
410
410
|
}).format(date);
|
|
411
411
|
};
|
|
412
|
-
var UpgradeContext =
|
|
412
|
+
var UpgradeContext = React10.createContext(void 0);
|
|
413
413
|
var UpgradeProvider = ({ children }) => {
|
|
414
|
-
const [isUpgradeSummaryVisible, setIsUpgradeSummaryVisible] =
|
|
414
|
+
const [isUpgradeSummaryVisible, setIsUpgradeSummaryVisible] = React10.useState(false);
|
|
415
415
|
const setUpgradeSummaryVisible = (visible) => {
|
|
416
416
|
setIsUpgradeSummaryVisible(visible);
|
|
417
417
|
};
|
|
@@ -431,12 +431,13 @@ var UpgradeProvider = ({ children }) => {
|
|
|
431
431
|
);
|
|
432
432
|
};
|
|
433
433
|
var useUpgrade = () => {
|
|
434
|
-
const context =
|
|
434
|
+
const context = React10.useContext(UpgradeContext);
|
|
435
435
|
if (context === void 0) {
|
|
436
436
|
throw new Error("useUpgrade must be used within an UpgradeProvider");
|
|
437
437
|
}
|
|
438
438
|
return context;
|
|
439
439
|
};
|
|
440
|
+
var CurrencyContext = React10.createContext(void 0);
|
|
440
441
|
|
|
441
442
|
// src/utils/currency.ts
|
|
442
443
|
var CURRENCY_SYMBOLS = {
|
|
@@ -523,25 +524,18 @@ function mapCountryToCurrency(countryCode) {
|
|
|
523
524
|
};
|
|
524
525
|
return countryToCurrency[countryCode] || "USD";
|
|
525
526
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
if (context === void 0) {
|
|
530
|
-
throw new Error("useCurrency must be used within a CurrencyProvider");
|
|
531
|
-
}
|
|
532
|
-
return context;
|
|
533
|
-
};
|
|
534
|
-
var CurrencyProvider = ({
|
|
535
|
-
children,
|
|
527
|
+
|
|
528
|
+
// src/hooks/useCountryAndCurrency.ts
|
|
529
|
+
var useCountryAndCurrency = ({
|
|
536
530
|
ipInfoToken,
|
|
537
|
-
defaultCurrency = "
|
|
531
|
+
defaultCurrency = "usd",
|
|
538
532
|
skipAutoDetect = false
|
|
539
|
-
}) => {
|
|
540
|
-
const [country, setCountry] =
|
|
541
|
-
const [currency, setCurrencyState] =
|
|
542
|
-
const [isLoading, setIsLoading] =
|
|
543
|
-
const [error, setError] =
|
|
544
|
-
|
|
533
|
+
} = {}) => {
|
|
534
|
+
const [country, setCountry] = React10.useState(null);
|
|
535
|
+
const [currency, setCurrencyState] = React10.useState(defaultCurrency);
|
|
536
|
+
const [isLoading, setIsLoading] = React10.useState(!skipAutoDetect);
|
|
537
|
+
const [error, setError] = React10.useState(null);
|
|
538
|
+
React10.useEffect(() => {
|
|
545
539
|
if (skipAutoDetect) {
|
|
546
540
|
setIsLoading(false);
|
|
547
541
|
return;
|
|
@@ -573,20 +567,46 @@ var CurrencyProvider = ({
|
|
|
573
567
|
const setCurrency = (newCurrency) => {
|
|
574
568
|
setCurrencyState(newCurrency);
|
|
575
569
|
};
|
|
570
|
+
return {
|
|
571
|
+
country,
|
|
572
|
+
currency,
|
|
573
|
+
isLoading,
|
|
574
|
+
error,
|
|
575
|
+
setCurrency
|
|
576
|
+
};
|
|
577
|
+
};
|
|
578
|
+
var useCurrency = () => {
|
|
579
|
+
const context = React10.useContext(CurrencyContext);
|
|
580
|
+
if (context === void 0) {
|
|
581
|
+
throw new Error("useCurrency must be used within a CurrencyProvider");
|
|
582
|
+
}
|
|
583
|
+
return context;
|
|
584
|
+
};
|
|
585
|
+
var CurrencyProvider = ({
|
|
586
|
+
children,
|
|
587
|
+
ipInfoToken,
|
|
588
|
+
defaultCurrency = "usd",
|
|
589
|
+
skipAutoDetect = false
|
|
590
|
+
}) => {
|
|
591
|
+
const { country, currency, isLoading, error, setCurrency } = useCountryAndCurrency({
|
|
592
|
+
ipInfoToken,
|
|
593
|
+
defaultCurrency,
|
|
594
|
+
skipAutoDetect
|
|
595
|
+
});
|
|
576
596
|
return /* @__PURE__ */ jsxRuntime.jsx(CurrencyContext.Provider, { value: { country, currency, isLoading, error, setCurrency }, children });
|
|
577
597
|
};
|
|
578
598
|
|
|
579
599
|
// src/hooks/usePlans.ts
|
|
580
600
|
var usePlans = () => {
|
|
581
601
|
const { currency } = useCurrency();
|
|
582
|
-
const [plans, setPlans] =
|
|
583
|
-
const [filteredPlans, setFilteredPlans] =
|
|
584
|
-
const [selectedPlan, setSelectedPlan] =
|
|
585
|
-
const [tierFilter, setTierFilter] =
|
|
586
|
-
const [billingCycle, setBillingCycle] =
|
|
587
|
-
const [loading, setLoading] =
|
|
588
|
-
const [error, setError] =
|
|
589
|
-
const fetchPlans =
|
|
602
|
+
const [plans, setPlans] = React10.useState([]);
|
|
603
|
+
const [filteredPlans, setFilteredPlans] = React10.useState([]);
|
|
604
|
+
const [selectedPlan, setSelectedPlan] = React10.useState(null);
|
|
605
|
+
const [tierFilter, setTierFilter] = React10.useState("all");
|
|
606
|
+
const [billingCycle, setBillingCycle] = React10.useState("monthly");
|
|
607
|
+
const [loading, setLoading] = React10.useState(false);
|
|
608
|
+
const [error, setError] = React10.useState(null);
|
|
609
|
+
const fetchPlans = React10.useCallback(async () => {
|
|
590
610
|
if (loading) return;
|
|
591
611
|
setLoading(true);
|
|
592
612
|
setError(null);
|
|
@@ -608,7 +628,7 @@ var usePlans = () => {
|
|
|
608
628
|
setLoading(false);
|
|
609
629
|
}
|
|
610
630
|
}, [loading]);
|
|
611
|
-
|
|
631
|
+
React10.useEffect(() => {
|
|
612
632
|
if (plans.length > 0 && tierFilter === "all") {
|
|
613
633
|
const uniqueUnits = getUniqueCandidateUnits(plans);
|
|
614
634
|
if (uniqueUnits.length > 0) {
|
|
@@ -616,17 +636,17 @@ var usePlans = () => {
|
|
|
616
636
|
}
|
|
617
637
|
}
|
|
618
638
|
}, [plans, tierFilter]);
|
|
619
|
-
|
|
639
|
+
React10.useEffect(() => {
|
|
620
640
|
let filtered = [...plans];
|
|
621
641
|
filtered = filterPlansByBillingCycle(filtered, billingCycle);
|
|
622
642
|
filtered = filterPlansByTier(filtered, tierFilter);
|
|
623
643
|
const sorted = sortPlansForDisplay(filtered);
|
|
624
644
|
setFilteredPlans(sorted);
|
|
625
645
|
}, [plans, tierFilter, billingCycle]);
|
|
626
|
-
const handlePlanSelect =
|
|
646
|
+
const handlePlanSelect = React10.useCallback((plan) => {
|
|
627
647
|
setSelectedPlan(plan);
|
|
628
648
|
}, []);
|
|
629
|
-
const handleUpgrade =
|
|
649
|
+
const handleUpgrade = React10.useCallback(async (externalId, options) => {
|
|
630
650
|
var _a;
|
|
631
651
|
if (!selectedPlan) return;
|
|
632
652
|
try {
|
|
@@ -648,14 +668,14 @@ var usePlans = () => {
|
|
|
648
668
|
alert("An error occurred. Please try again.");
|
|
649
669
|
}
|
|
650
670
|
}, [selectedPlan, currency]);
|
|
651
|
-
const clearPlans =
|
|
671
|
+
const clearPlans = React10.useCallback(() => {
|
|
652
672
|
setPlans([]);
|
|
653
673
|
setFilteredPlans([]);
|
|
654
674
|
setSelectedPlan(null);
|
|
655
675
|
setError(null);
|
|
656
676
|
setTierFilter("all");
|
|
657
677
|
}, []);
|
|
658
|
-
const clearSelectedPlan2 =
|
|
678
|
+
const clearSelectedPlan2 = React10.useCallback(() => {
|
|
659
679
|
setSelectedPlan(null);
|
|
660
680
|
}, []);
|
|
661
681
|
const dropdownOptions = getDropdownOptions(plans);
|
|
@@ -741,18 +761,18 @@ var useTransactions = ({
|
|
|
741
761
|
initialFilters = {},
|
|
742
762
|
autoFetch = false
|
|
743
763
|
}) => {
|
|
744
|
-
const [transactions, setTransactions] =
|
|
745
|
-
const [allTransactions, setAllTransactions] =
|
|
746
|
-
const [loading, setLoading] =
|
|
747
|
-
const [error, setError] =
|
|
748
|
-
const [filters, setFilters] =
|
|
764
|
+
const [transactions, setTransactions] = React10.useState([]);
|
|
765
|
+
const [allTransactions, setAllTransactions] = React10.useState([]);
|
|
766
|
+
const [loading, setLoading] = React10.useState(false);
|
|
767
|
+
const [error, setError] = React10.useState(null);
|
|
768
|
+
const [filters, setFilters] = React10.useState({
|
|
749
769
|
...DEFAULT_FILTERS,
|
|
750
770
|
...initialFilters
|
|
751
771
|
});
|
|
752
|
-
const [meta, setMeta] =
|
|
753
|
-
const [isBackendPaginated, setIsBackendPaginated] =
|
|
754
|
-
const hasAutoFetchedRef =
|
|
755
|
-
const fetchTransactions =
|
|
772
|
+
const [meta, setMeta] = React10.useState(null);
|
|
773
|
+
const [isBackendPaginated, setIsBackendPaginated] = React10.useState(false);
|
|
774
|
+
const hasAutoFetchedRef = React10.useRef(false);
|
|
775
|
+
const fetchTransactions = React10.useCallback(async () => {
|
|
756
776
|
if (!externalId) return;
|
|
757
777
|
setLoading(true);
|
|
758
778
|
setError(null);
|
|
@@ -791,7 +811,7 @@ var useTransactions = ({
|
|
|
791
811
|
setLoading(false);
|
|
792
812
|
}
|
|
793
813
|
}, [externalId, filters]);
|
|
794
|
-
const updateFilters =
|
|
814
|
+
const updateFilters = React10.useCallback((newFilters) => {
|
|
795
815
|
setFilters((prev) => ({
|
|
796
816
|
...prev,
|
|
797
817
|
...newFilters,
|
|
@@ -799,7 +819,7 @@ var useTransactions = ({
|
|
|
799
819
|
page: newFilters.page !== void 0 ? newFilters.page : 1
|
|
800
820
|
}));
|
|
801
821
|
}, []);
|
|
802
|
-
|
|
822
|
+
React10.useEffect(() => {
|
|
803
823
|
if (!isBackendPaginated && allTransactions.length > 0) {
|
|
804
824
|
const filteredTransactions = applyFrontendFilters(allTransactions, filters);
|
|
805
825
|
const paginatedResult = applyFrontendPagination(filteredTransactions, filters);
|
|
@@ -807,19 +827,19 @@ var useTransactions = ({
|
|
|
807
827
|
setMeta(paginatedResult.meta);
|
|
808
828
|
}
|
|
809
829
|
}, [filters, allTransactions, isBackendPaginated]);
|
|
810
|
-
const clearFilters =
|
|
830
|
+
const clearFilters = React10.useCallback(() => {
|
|
811
831
|
setFilters(DEFAULT_FILTERS);
|
|
812
832
|
}, []);
|
|
813
|
-
const refetch =
|
|
833
|
+
const refetch = React10.useCallback(async () => {
|
|
814
834
|
await fetchTransactions();
|
|
815
835
|
}, [fetchTransactions]);
|
|
816
|
-
|
|
836
|
+
React10.useEffect(() => {
|
|
817
837
|
if (autoFetch && externalId && !hasAutoFetchedRef.current) {
|
|
818
838
|
hasAutoFetchedRef.current = true;
|
|
819
839
|
fetchTransactions();
|
|
820
840
|
}
|
|
821
841
|
}, [autoFetch, externalId, fetchTransactions]);
|
|
822
|
-
|
|
842
|
+
React10.useEffect(() => {
|
|
823
843
|
if (!autoFetch) return;
|
|
824
844
|
const hasNonPaginationFilters = filters.startDate !== void 0 || filters.endDate !== void 0 || filters.status !== void 0;
|
|
825
845
|
const shouldFetch = isBackendPaginated || allTransactions.length === 0 && hasNonPaginationFilters;
|
|
@@ -846,10 +866,10 @@ var usePagination = ({
|
|
|
846
866
|
initialPage = 1,
|
|
847
867
|
initialLimit = 10
|
|
848
868
|
} = {}) => {
|
|
849
|
-
const [currentPage, setCurrentPage] =
|
|
850
|
-
const [limit, setLimitState] =
|
|
851
|
-
const [meta, setMeta] =
|
|
852
|
-
const goToPage =
|
|
869
|
+
const [currentPage, setCurrentPage] = React10.useState(initialPage);
|
|
870
|
+
const [limit, setLimitState] = React10.useState(initialLimit);
|
|
871
|
+
const [meta, setMeta] = React10.useState(null);
|
|
872
|
+
const goToPage = React10.useCallback((page) => {
|
|
853
873
|
if (meta) {
|
|
854
874
|
const validPage = Math.max(1, Math.min(page, meta.totalPages));
|
|
855
875
|
setCurrentPage(validPage);
|
|
@@ -857,29 +877,29 @@ var usePagination = ({
|
|
|
857
877
|
setCurrentPage(Math.max(1, page));
|
|
858
878
|
}
|
|
859
879
|
}, [meta]);
|
|
860
|
-
const goToNextPage =
|
|
880
|
+
const goToNextPage = React10.useCallback(() => {
|
|
861
881
|
if (meta && meta.hasNextPage) {
|
|
862
882
|
setCurrentPage((prev) => prev + 1);
|
|
863
883
|
}
|
|
864
884
|
}, [meta]);
|
|
865
|
-
const goToPreviousPage =
|
|
885
|
+
const goToPreviousPage = React10.useCallback(() => {
|
|
866
886
|
if (meta && meta.hasPreviousPage) {
|
|
867
887
|
setCurrentPage((prev) => prev - 1);
|
|
868
888
|
}
|
|
869
889
|
}, [meta]);
|
|
870
|
-
const goToFirstPage =
|
|
890
|
+
const goToFirstPage = React10.useCallback(() => {
|
|
871
891
|
setCurrentPage(1);
|
|
872
892
|
}, []);
|
|
873
|
-
const goToLastPage =
|
|
893
|
+
const goToLastPage = React10.useCallback(() => {
|
|
874
894
|
if (meta) {
|
|
875
895
|
setCurrentPage(meta.totalPages);
|
|
876
896
|
}
|
|
877
897
|
}, [meta]);
|
|
878
|
-
const setLimit =
|
|
898
|
+
const setLimit = React10.useCallback((newLimit) => {
|
|
879
899
|
setLimitState(newLimit);
|
|
880
900
|
setCurrentPage(1);
|
|
881
901
|
}, []);
|
|
882
|
-
const reset =
|
|
902
|
+
const reset = React10.useCallback(() => {
|
|
883
903
|
setCurrentPage(initialPage);
|
|
884
904
|
setLimitState(initialLimit);
|
|
885
905
|
setMeta(null);
|
|
@@ -902,9 +922,9 @@ var useCancelSubscription = ({
|
|
|
902
922
|
onSuccess,
|
|
903
923
|
onError
|
|
904
924
|
} = {}) => {
|
|
905
|
-
const [loading, setLoading] =
|
|
906
|
-
const [error, setError] =
|
|
907
|
-
const cancelSubscription =
|
|
925
|
+
const [loading, setLoading] = React10.useState(false);
|
|
926
|
+
const [error, setError] = React10.useState(null);
|
|
927
|
+
const cancelSubscription = React10.useCallback(async (externalId, options) => {
|
|
908
928
|
if (!externalId) {
|
|
909
929
|
const errorMsg = "External ID is required";
|
|
910
930
|
setError(errorMsg);
|
|
@@ -933,7 +953,7 @@ var useCancelSubscription = ({
|
|
|
933
953
|
setLoading(false);
|
|
934
954
|
}
|
|
935
955
|
}, [onSuccess, onError]);
|
|
936
|
-
const reset =
|
|
956
|
+
const reset = React10.useCallback(() => {
|
|
937
957
|
setLoading(false);
|
|
938
958
|
setError(null);
|
|
939
959
|
}, []);
|
|
@@ -949,9 +969,9 @@ var useCustomerPortal = ({
|
|
|
949
969
|
onError,
|
|
950
970
|
returnPath = "/dashboard"
|
|
951
971
|
} = {}) => {
|
|
952
|
-
const [loading, setLoading] =
|
|
953
|
-
const [error, setError] =
|
|
954
|
-
const openCustomerPortal =
|
|
972
|
+
const [loading, setLoading] = React10.useState(false);
|
|
973
|
+
const [error, setError] = React10.useState(null);
|
|
974
|
+
const openCustomerPortal = React10.useCallback(async (externalId) => {
|
|
955
975
|
var _a;
|
|
956
976
|
if (!externalId) {
|
|
957
977
|
const errorMsg = "External ID is required";
|
|
@@ -988,7 +1008,7 @@ var useCustomerPortal = ({
|
|
|
988
1008
|
setLoading(false);
|
|
989
1009
|
}
|
|
990
1010
|
}, [onSuccess, onError, returnPath]);
|
|
991
|
-
const reset =
|
|
1011
|
+
const reset = React10.useCallback(() => {
|
|
992
1012
|
setLoading(false);
|
|
993
1013
|
setError(null);
|
|
994
1014
|
}, []);
|
|
@@ -999,13 +1019,13 @@ var useCustomerPortal = ({
|
|
|
999
1019
|
reset
|
|
1000
1020
|
};
|
|
1001
1021
|
};
|
|
1002
|
-
var NavigationContext =
|
|
1022
|
+
var NavigationContext = React10.createContext(void 0);
|
|
1003
1023
|
var NavigationProvider = ({
|
|
1004
1024
|
children,
|
|
1005
1025
|
initialPage = "dashboard"
|
|
1006
1026
|
}) => {
|
|
1007
|
-
const [currentPage, setCurrentPage] =
|
|
1008
|
-
const [history, setHistory] =
|
|
1027
|
+
const [currentPage, setCurrentPage] = React10.useState(initialPage);
|
|
1028
|
+
const [history, setHistory] = React10.useState([initialPage]);
|
|
1009
1029
|
const navigateTo = (page) => {
|
|
1010
1030
|
setCurrentPage(page);
|
|
1011
1031
|
setHistory((prev) => [...prev, page]);
|
|
@@ -1022,7 +1042,7 @@ var NavigationProvider = ({
|
|
|
1022
1042
|
return /* @__PURE__ */ jsxRuntime.jsx(NavigationContext.Provider, { value: { currentPage, navigateTo, goBack }, children });
|
|
1023
1043
|
};
|
|
1024
1044
|
var useNavigation = () => {
|
|
1025
|
-
const context =
|
|
1045
|
+
const context = React10.useContext(NavigationContext);
|
|
1026
1046
|
if (!context) {
|
|
1027
1047
|
throw new Error("useNavigation must be used within NavigationProvider");
|
|
1028
1048
|
}
|
|
@@ -1106,8 +1126,8 @@ var TierFilterDropdown = ({
|
|
|
1106
1126
|
selectedValue,
|
|
1107
1127
|
onSelect
|
|
1108
1128
|
}) => {
|
|
1109
|
-
const dropdownRef =
|
|
1110
|
-
|
|
1129
|
+
const dropdownRef = React10.useRef(null);
|
|
1130
|
+
React10.useEffect(() => {
|
|
1111
1131
|
const handleClickOutside = (event) => {
|
|
1112
1132
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
1113
1133
|
if (isOpen) {
|
|
@@ -1472,7 +1492,7 @@ var PlanSelector = ({
|
|
|
1472
1492
|
onBillingCycleChange,
|
|
1473
1493
|
activePlanCode
|
|
1474
1494
|
}) => {
|
|
1475
|
-
const [isDropdownOpen, setIsDropdownOpen] =
|
|
1495
|
+
const [isDropdownOpen, setIsDropdownOpen] = React10.useState(false);
|
|
1476
1496
|
const handleDropdownToggle = () => {
|
|
1477
1497
|
setIsDropdownOpen(!isDropdownOpen);
|
|
1478
1498
|
};
|
|
@@ -1587,7 +1607,14 @@ var ChangeCardButton = ({
|
|
|
1587
1607
|
);
|
|
1588
1608
|
};
|
|
1589
1609
|
var PaymentCancelView = ({ details, dashboardUrl = "/dashboard", planUrl = "/plans", supportUrl = "/support" }) => {
|
|
1590
|
-
const { navigateTo
|
|
1610
|
+
const { navigateTo } = useNavigation();
|
|
1611
|
+
const handleTryAgain = () => {
|
|
1612
|
+
if (planUrl && planUrl.startsWith("/")) {
|
|
1613
|
+
window.history.back();
|
|
1614
|
+
} else {
|
|
1615
|
+
navigateTo("dashboard");
|
|
1616
|
+
}
|
|
1617
|
+
};
|
|
1591
1618
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-md mx-auto bg-white rounded-lg shadow-md overflow-hidden", children: [
|
|
1592
1619
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-gradient-to-r from-orange-500 to-red-500 text-white p-6 text-center", children: [
|
|
1593
1620
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-2 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1650,7 +1677,7 @@ var PaymentCancelView = ({ details, dashboardUrl = "/dashboard", planUrl = "/pla
|
|
|
1650
1677
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1651
1678
|
"button",
|
|
1652
1679
|
{
|
|
1653
|
-
onClick:
|
|
1680
|
+
onClick: handleTryAgain,
|
|
1654
1681
|
className: "w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-4 rounded-md transition-colors",
|
|
1655
1682
|
children: "Try Payment Again"
|
|
1656
1683
|
}
|
|
@@ -1834,7 +1861,7 @@ var Layout = ({ children, hideHeader = false, hideFooter = false }) => {
|
|
|
1834
1861
|
] });
|
|
1835
1862
|
};
|
|
1836
1863
|
var usePaymentParams = () => {
|
|
1837
|
-
return
|
|
1864
|
+
return React10.useMemo(() => {
|
|
1838
1865
|
const params = new URLSearchParams(window.location.search);
|
|
1839
1866
|
return {
|
|
1840
1867
|
gateway: params.get("gateway") || void 0,
|
|
@@ -1865,7 +1892,7 @@ var PaymentSuccessPage = ({
|
|
|
1865
1892
|
initialFilters: { page: 1, limit: 100 },
|
|
1866
1893
|
autoFetch: !!externalId
|
|
1867
1894
|
});
|
|
1868
|
-
const invoiceDownloadUrl =
|
|
1895
|
+
const invoiceDownloadUrl = React10.useMemo(() => {
|
|
1869
1896
|
if (propInvoiceDownloadUrl) return propInvoiceDownloadUrl;
|
|
1870
1897
|
if (!transactions || transactions.length === 0) return void 0;
|
|
1871
1898
|
const withOrder = transactions.filter((t) => typeof t.order === "number");
|
|
@@ -2379,7 +2406,7 @@ var TransactionPagination = ({
|
|
|
2379
2406
|
children: "Previous"
|
|
2380
2407
|
}
|
|
2381
2408
|
),
|
|
2382
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center space-x-1", children: getVisiblePages().map((page, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2409
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center space-x-1", children: getVisiblePages().map((page, index) => /* @__PURE__ */ jsxRuntime.jsx(React10__default.default.Fragment, { children: page === "..." ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "px-3 py-2 text-sm text-gray-500", children: "..." }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2383
2410
|
"button",
|
|
2384
2411
|
{
|
|
2385
2412
|
onClick: () => onPageChange(page),
|
|
@@ -2425,7 +2452,7 @@ var TransactionModal = ({
|
|
|
2425
2452
|
autoFetch: true
|
|
2426
2453
|
// Enable auto-fetch so it works when modal opens
|
|
2427
2454
|
});
|
|
2428
|
-
|
|
2455
|
+
React10.useEffect(() => {
|
|
2429
2456
|
if (isOpen && externalId) {
|
|
2430
2457
|
fetchTransactions();
|
|
2431
2458
|
}
|
|
@@ -2943,10 +2970,10 @@ var SubscriptionDetails = ({
|
|
|
2943
2970
|
customActions = [],
|
|
2944
2971
|
className = ""
|
|
2945
2972
|
}) => {
|
|
2946
|
-
const [isTransactionModalOpen, setIsTransactionModalOpen] =
|
|
2947
|
-
const [showCancelConfirmation, setShowCancelConfirmation] =
|
|
2948
|
-
const [localSubscription, setLocalSubscription] =
|
|
2949
|
-
|
|
2973
|
+
const [isTransactionModalOpen, setIsTransactionModalOpen] = React10.useState(false);
|
|
2974
|
+
const [showCancelConfirmation, setShowCancelConfirmation] = React10.useState(false);
|
|
2975
|
+
const [localSubscription, setLocalSubscription] = React10.useState(subscription);
|
|
2976
|
+
React10.useEffect(() => {
|
|
2950
2977
|
setLocalSubscription(subscription);
|
|
2951
2978
|
}, [subscription]);
|
|
2952
2979
|
const { cancelSubscription, loading: cancelLoading } = useCancelSubscription({
|
|
@@ -3072,9 +3099,9 @@ var UpgradeSummary = ({
|
|
|
3072
3099
|
billableMetricCode
|
|
3073
3100
|
}) => {
|
|
3074
3101
|
const { currency } = useCurrency();
|
|
3075
|
-
const [checkoutInfo, setCheckoutInfo] =
|
|
3076
|
-
const [loading, setLoading] =
|
|
3077
|
-
|
|
3102
|
+
const [checkoutInfo, setCheckoutInfo] = React10.useState(null);
|
|
3103
|
+
const [loading, setLoading] = React10.useState(false);
|
|
3104
|
+
React10.useEffect(() => {
|
|
3078
3105
|
const planToDisplay2 = selectedPlan || currentPlan;
|
|
3079
3106
|
if (!planToDisplay2 || !isVisible || Number(planToDisplay2.fixedCost) === 0) {
|
|
3080
3107
|
setCheckoutInfo(null);
|
|
@@ -3230,9 +3257,9 @@ var UpgradeSummary = ({
|
|
|
3230
3257
|
}
|
|
3231
3258
|
) }) });
|
|
3232
3259
|
};
|
|
3233
|
-
var SubOSThemeContext =
|
|
3260
|
+
var SubOSThemeContext = React10.createContext(void 0);
|
|
3234
3261
|
var useSubOSTheme = () => {
|
|
3235
|
-
const context =
|
|
3262
|
+
const context = React10.useContext(SubOSThemeContext);
|
|
3236
3263
|
if (!context) {
|
|
3237
3264
|
throw new Error("useSubOSTheme must be used within a SubOSThemeProvider");
|
|
3238
3265
|
}
|
|
@@ -3243,8 +3270,8 @@ var SubOSThemeProvider = ({
|
|
|
3243
3270
|
theme = {},
|
|
3244
3271
|
className = ""
|
|
3245
3272
|
}) => {
|
|
3246
|
-
const [currentTheme, setCurrentTheme] =
|
|
3247
|
-
const cssVariables =
|
|
3273
|
+
const [currentTheme, setCurrentTheme] = React10__default.default.useState(theme);
|
|
3274
|
+
const cssVariables = React10__default.default.useMemo(() => {
|
|
3248
3275
|
const vars = {};
|
|
3249
3276
|
if (currentTheme.primaryColors) {
|
|
3250
3277
|
Object.entries(currentTheme.primaryColors).forEach(([key, value]) => {
|
|
@@ -3293,7 +3320,7 @@ var SubOSThemeProvider = ({
|
|
|
3293
3320
|
if (currentTheme.shadowCardHover) vars["--subos-shadow-card-hover"] = currentTheme.shadowCardHover;
|
|
3294
3321
|
return vars;
|
|
3295
3322
|
}, [currentTheme]);
|
|
3296
|
-
const contextValue =
|
|
3323
|
+
const contextValue = React10__default.default.useMemo(() => ({
|
|
3297
3324
|
theme: currentTheme,
|
|
3298
3325
|
setTheme: setCurrentTheme
|
|
3299
3326
|
}), [currentTheme]);
|
|
@@ -3308,7 +3335,7 @@ var SubOSThemeProvider = ({
|
|
|
3308
3335
|
};
|
|
3309
3336
|
var useApplyHostTheme = (hostTheme) => {
|
|
3310
3337
|
const { setTheme } = useSubOSTheme();
|
|
3311
|
-
|
|
3338
|
+
React10__default.default.useEffect(() => {
|
|
3312
3339
|
if (hostTheme) {
|
|
3313
3340
|
setTheme(hostTheme);
|
|
3314
3341
|
}
|
|
@@ -3388,7 +3415,7 @@ var Pagination = ({
|
|
|
3388
3415
|
children: "Previous"
|
|
3389
3416
|
}
|
|
3390
3417
|
),
|
|
3391
|
-
pageNumbers.map((page, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3418
|
+
pageNumbers.map((page, index) => /* @__PURE__ */ jsxRuntime.jsx(React10__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(
|
|
3392
3419
|
"button",
|
|
3393
3420
|
{
|
|
3394
3421
|
onClick: () => onPageChange(page),
|
|
@@ -3415,15 +3442,15 @@ var DashboardPage = ({
|
|
|
3415
3442
|
var _a, _b, _c, _d;
|
|
3416
3443
|
const subscription = useSubscription();
|
|
3417
3444
|
const plans = usePlans();
|
|
3418
|
-
const lastLoadedIdRef =
|
|
3419
|
-
|
|
3445
|
+
const lastLoadedIdRef = React10.useRef(null);
|
|
3446
|
+
React10.useEffect(() => {
|
|
3420
3447
|
if (lastLoadedIdRef.current !== externalId) {
|
|
3421
3448
|
subscription.fetchSubscription(externalId);
|
|
3422
3449
|
plans.fetchPlans();
|
|
3423
3450
|
lastLoadedIdRef.current = externalId;
|
|
3424
3451
|
}
|
|
3425
3452
|
}, [externalId]);
|
|
3426
|
-
|
|
3453
|
+
React10.useEffect(() => {
|
|
3427
3454
|
registerClearSelectedPlan(plans.clearSelectedPlan);
|
|
3428
3455
|
return () => {
|
|
3429
3456
|
unregisterClearSelectedPlan();
|
|
@@ -3488,9 +3515,9 @@ var DashboardPage = ({
|
|
|
3488
3515
|
] }) }) });
|
|
3489
3516
|
};
|
|
3490
3517
|
var useProcessPaymentCancel = (params) => {
|
|
3491
|
-
const [loading, setLoading] =
|
|
3492
|
-
const [error, setError] =
|
|
3493
|
-
|
|
3518
|
+
const [loading, setLoading] = React10.useState(true);
|
|
3519
|
+
const [error, setError] = React10.useState(null);
|
|
3520
|
+
React10.useEffect(() => {
|
|
3494
3521
|
const run = async () => {
|
|
3495
3522
|
try {
|
|
3496
3523
|
const qs = new URLSearchParams({
|
|
@@ -3634,6 +3661,7 @@ exports.transactionApi = transactionApi;
|
|
|
3634
3661
|
exports.unregisterClearSelectedPlan = unregisterClearSelectedPlan;
|
|
3635
3662
|
exports.useApplyHostTheme = useApplyHostTheme;
|
|
3636
3663
|
exports.useCancelSubscription = useCancelSubscription;
|
|
3664
|
+
exports.useCountryAndCurrency = useCountryAndCurrency;
|
|
3637
3665
|
exports.useCurrency = useCurrency;
|
|
3638
3666
|
exports.useCustomerPortal = useCustomerPortal;
|
|
3639
3667
|
exports.useNavigation = useNavigation;
|