azirid-react 0.7.0 → 0.8.0
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 +414 -359
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -5
- package/dist/index.d.ts +76 -5
- package/dist/index.js +414 -360
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -513,6 +513,86 @@ function removeStyles() {
|
|
|
513
513
|
document.getElementById(STYLE_ID)?.remove();
|
|
514
514
|
injected = false;
|
|
515
515
|
}
|
|
516
|
+
function useAuthMutations(deps) {
|
|
517
|
+
const {
|
|
518
|
+
client,
|
|
519
|
+
props,
|
|
520
|
+
setUser,
|
|
521
|
+
setError,
|
|
522
|
+
updateAccessToken,
|
|
523
|
+
saveSessionTokens,
|
|
524
|
+
normalizeToken,
|
|
525
|
+
withAppContext,
|
|
526
|
+
clearSession
|
|
527
|
+
} = deps;
|
|
528
|
+
const queryClient = reactQuery.useQueryClient();
|
|
529
|
+
const loginMutation = reactQuery.useMutation({
|
|
530
|
+
mutationFn: (data) => client.post(client.paths.login, withAppContext(data)),
|
|
531
|
+
onSuccess: (data) => {
|
|
532
|
+
setUser(data.user);
|
|
533
|
+
updateAccessToken(normalizeToken(data));
|
|
534
|
+
saveSessionTokens(data);
|
|
535
|
+
setError(null);
|
|
536
|
+
props.onLoginSuccess?.(data);
|
|
537
|
+
},
|
|
538
|
+
onError: (err) => {
|
|
539
|
+
setError(err.message);
|
|
540
|
+
props.onError?.(err.message);
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
const signupMutation = reactQuery.useMutation({
|
|
544
|
+
mutationFn: (data) => {
|
|
545
|
+
const { confirmPassword: _, ...payload } = data;
|
|
546
|
+
return client.post(client.paths.signup, withAppContext({ ...payload }));
|
|
547
|
+
},
|
|
548
|
+
onSuccess: (data) => {
|
|
549
|
+
setUser(data.user);
|
|
550
|
+
updateAccessToken(normalizeToken(data));
|
|
551
|
+
saveSessionTokens(data);
|
|
552
|
+
setError(null);
|
|
553
|
+
props.onSignupSuccess?.(data);
|
|
554
|
+
},
|
|
555
|
+
onError: (err) => {
|
|
556
|
+
setError(err.message);
|
|
557
|
+
props.onError?.(err.message);
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
const logoutMutation = reactQuery.useMutation({
|
|
561
|
+
mutationFn: () => client.post(client.paths.logout),
|
|
562
|
+
onSettled: () => {
|
|
563
|
+
clearSession();
|
|
564
|
+
setError(null);
|
|
565
|
+
queryClient.clear();
|
|
566
|
+
props.onLogoutSuccess?.();
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
const refreshFn = react.useCallback(async () => {
|
|
570
|
+
try {
|
|
571
|
+
await client.refreshSession();
|
|
572
|
+
updateAccessToken(client.getAccessToken());
|
|
573
|
+
} catch (err) {
|
|
574
|
+
clearSession();
|
|
575
|
+
queryClient.clear();
|
|
576
|
+
props.onSessionExpired?.();
|
|
577
|
+
throw err;
|
|
578
|
+
}
|
|
579
|
+
}, [client, queryClient, props, updateAccessToken, clearSession]);
|
|
580
|
+
const switchTenantFn = react.useCallback(
|
|
581
|
+
async (tenantId) => {
|
|
582
|
+
await client.refreshSession({ tenantId });
|
|
583
|
+
updateAccessToken(client.getAccessToken());
|
|
584
|
+
await queryClient.invalidateQueries({ queryKey: ["azirid-access"] });
|
|
585
|
+
},
|
|
586
|
+
[client, queryClient, updateAccessToken]
|
|
587
|
+
);
|
|
588
|
+
return {
|
|
589
|
+
loginMutation,
|
|
590
|
+
signupMutation,
|
|
591
|
+
logoutMutation,
|
|
592
|
+
refreshFn,
|
|
593
|
+
switchTenantFn
|
|
594
|
+
};
|
|
595
|
+
}
|
|
516
596
|
var AziridContext = react.createContext(null);
|
|
517
597
|
AziridContext.displayName = "AziridContext";
|
|
518
598
|
var ClientContext = react.createContext(null);
|
|
@@ -545,7 +625,6 @@ function AziridProviderInner({
|
|
|
545
625
|
client,
|
|
546
626
|
props
|
|
547
627
|
}) {
|
|
548
|
-
const queryClient = reactQuery.useQueryClient();
|
|
549
628
|
const [user, setUser] = react.useState(null);
|
|
550
629
|
const [accessToken, setAccessToken] = react.useState(null);
|
|
551
630
|
const [error, setError] = react.useState(null);
|
|
@@ -683,65 +762,23 @@ function AziridProviderInner({
|
|
|
683
762
|
(data) => data.at ?? data.accessToken,
|
|
684
763
|
[]
|
|
685
764
|
);
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
const { confirmPassword: _, ...payload } = data;
|
|
703
|
-
return client.post(client.paths.signup, withAppContext({ ...payload }));
|
|
704
|
-
},
|
|
705
|
-
onSuccess: (data) => {
|
|
706
|
-
setUser(data.user);
|
|
707
|
-
updateAccessToken(normalizeToken(data));
|
|
708
|
-
saveSessionTokens(data);
|
|
709
|
-
setError(null);
|
|
710
|
-
props.onSignupSuccess?.(data);
|
|
711
|
-
},
|
|
712
|
-
onError: (err) => {
|
|
713
|
-
setError(err.message);
|
|
714
|
-
props.onError?.(err.message);
|
|
715
|
-
}
|
|
716
|
-
});
|
|
717
|
-
const logoutMutation = reactQuery.useMutation({
|
|
718
|
-
mutationFn: () => client.post(client.paths.logout),
|
|
719
|
-
onSettled: () => {
|
|
720
|
-
clearSession();
|
|
721
|
-
setError(null);
|
|
722
|
-
queryClient.clear();
|
|
723
|
-
props.onLogoutSuccess?.();
|
|
724
|
-
}
|
|
765
|
+
const {
|
|
766
|
+
loginMutation,
|
|
767
|
+
signupMutation,
|
|
768
|
+
logoutMutation,
|
|
769
|
+
refreshFn,
|
|
770
|
+
switchTenantFn
|
|
771
|
+
} = useAuthMutations({
|
|
772
|
+
client,
|
|
773
|
+
props,
|
|
774
|
+
setUser,
|
|
775
|
+
setError,
|
|
776
|
+
updateAccessToken,
|
|
777
|
+
saveSessionTokens,
|
|
778
|
+
normalizeToken,
|
|
779
|
+
withAppContext,
|
|
780
|
+
clearSession
|
|
725
781
|
});
|
|
726
|
-
const refreshFn = react.useCallback(async () => {
|
|
727
|
-
try {
|
|
728
|
-
await client.refreshSession();
|
|
729
|
-
updateAccessToken(client.getAccessToken());
|
|
730
|
-
} catch (err) {
|
|
731
|
-
clearSession();
|
|
732
|
-
queryClient.clear();
|
|
733
|
-
props.onSessionExpired?.();
|
|
734
|
-
throw err;
|
|
735
|
-
}
|
|
736
|
-
}, [client, queryClient, props, updateAccessToken, clearSession]);
|
|
737
|
-
const switchTenantFn = react.useCallback(
|
|
738
|
-
async (tenantId) => {
|
|
739
|
-
await client.refreshSession({ tenantId });
|
|
740
|
-
updateAccessToken(client.getAccessToken());
|
|
741
|
-
await queryClient.invalidateQueries({ queryKey: ["azirid-access"] });
|
|
742
|
-
},
|
|
743
|
-
[client, queryClient, updateAccessToken]
|
|
744
|
-
);
|
|
745
782
|
const login = react.useCallback(
|
|
746
783
|
(data) => loginMutation.mutate(data),
|
|
747
784
|
[loginMutation]
|
|
@@ -1716,6 +1753,20 @@ function ReferralStats({ className, style }) {
|
|
|
1716
1753
|
] });
|
|
1717
1754
|
}
|
|
1718
1755
|
ReferralStats.displayName = "ReferralStats";
|
|
1756
|
+
|
|
1757
|
+
// ../shared/dist/index.js
|
|
1758
|
+
function formatAmount(amount, currency) {
|
|
1759
|
+
try {
|
|
1760
|
+
return new Intl.NumberFormat(void 0, {
|
|
1761
|
+
style: "currency",
|
|
1762
|
+
currency,
|
|
1763
|
+
minimumFractionDigits: 0,
|
|
1764
|
+
maximumFractionDigits: 2
|
|
1765
|
+
}).format(amount / 100);
|
|
1766
|
+
} catch {
|
|
1767
|
+
return `${currency} ${(amount / 100).toFixed(2)}`;
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1719
1770
|
function usePlans() {
|
|
1720
1771
|
const client = useAccessClient();
|
|
1721
1772
|
return reactQuery.useQuery({
|
|
@@ -1881,30 +1932,42 @@ var cancelStyle = {
|
|
|
1881
1932
|
cursor: "pointer",
|
|
1882
1933
|
fontFamily: "inherit"
|
|
1883
1934
|
};
|
|
1935
|
+
var styles3 = {
|
|
1936
|
+
featuresList: {
|
|
1937
|
+
listStyle: "none",
|
|
1938
|
+
padding: 0,
|
|
1939
|
+
margin: "0 0 24px 0",
|
|
1940
|
+
flex: 1
|
|
1941
|
+
},
|
|
1942
|
+
featureItem: {
|
|
1943
|
+
display: "flex",
|
|
1944
|
+
alignItems: "center",
|
|
1945
|
+
gap: "8px",
|
|
1946
|
+
padding: "6px 0",
|
|
1947
|
+
fontSize: "14px",
|
|
1948
|
+
color: "#374151"
|
|
1949
|
+
},
|
|
1950
|
+
checkmark: {
|
|
1951
|
+
color: "#10b981",
|
|
1952
|
+
fontSize: "16px",
|
|
1953
|
+
fontWeight: 700,
|
|
1954
|
+
flexShrink: 0
|
|
1955
|
+
}
|
|
1956
|
+
};
|
|
1957
|
+
function PricingFeatureList({ features }) {
|
|
1958
|
+
if (!features || features.length === 0) return null;
|
|
1959
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { style: styles3.featuresList, children: features.map((feature, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { style: styles3.featureItem, children: [
|
|
1960
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: styles3.checkmark, "aria-hidden": "true", children: "\u2713" }),
|
|
1961
|
+
feature
|
|
1962
|
+
] }, i)) });
|
|
1963
|
+
}
|
|
1964
|
+
PricingFeatureList.displayName = "PricingFeatureList";
|
|
1884
1965
|
var intervalLabels = {
|
|
1885
1966
|
MONTHLY: "/mo",
|
|
1886
1967
|
YEARLY: "/yr",
|
|
1887
1968
|
ONE_TIME: ""
|
|
1888
1969
|
};
|
|
1889
|
-
|
|
1890
|
-
try {
|
|
1891
|
-
return new Intl.NumberFormat(void 0, {
|
|
1892
|
-
style: "currency",
|
|
1893
|
-
currency,
|
|
1894
|
-
minimumFractionDigits: 0,
|
|
1895
|
-
maximumFractionDigits: 2
|
|
1896
|
-
}).format(amount / 100);
|
|
1897
|
-
} catch {
|
|
1898
|
-
return `${currency} ${(amount / 100).toFixed(2)}`;
|
|
1899
|
-
}
|
|
1900
|
-
}
|
|
1901
|
-
var styles3 = {
|
|
1902
|
-
grid: (columns) => ({
|
|
1903
|
-
display: "grid",
|
|
1904
|
-
gridTemplateColumns: `repeat(${columns}, 1fr)`,
|
|
1905
|
-
gap: "24px",
|
|
1906
|
-
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'
|
|
1907
|
-
}),
|
|
1970
|
+
var styles4 = {
|
|
1908
1971
|
card: (isCurrentPlan) => ({
|
|
1909
1972
|
border: isCurrentPlan ? "2px solid #6366f1" : "1px solid #e5e7eb",
|
|
1910
1973
|
borderRadius: "12px",
|
|
@@ -1955,26 +2018,6 @@ var styles3 = {
|
|
|
1955
2018
|
fontSize: "16px",
|
|
1956
2019
|
color: "#6b7280"
|
|
1957
2020
|
},
|
|
1958
|
-
featuresList: {
|
|
1959
|
-
listStyle: "none",
|
|
1960
|
-
padding: 0,
|
|
1961
|
-
margin: "0 0 24px 0",
|
|
1962
|
-
flex: 1
|
|
1963
|
-
},
|
|
1964
|
-
featureItem: {
|
|
1965
|
-
display: "flex",
|
|
1966
|
-
alignItems: "center",
|
|
1967
|
-
gap: "8px",
|
|
1968
|
-
padding: "6px 0",
|
|
1969
|
-
fontSize: "14px",
|
|
1970
|
-
color: "#374151"
|
|
1971
|
-
},
|
|
1972
|
-
checkmark: {
|
|
1973
|
-
color: "#10b981",
|
|
1974
|
-
fontSize: "16px",
|
|
1975
|
-
fontWeight: 700,
|
|
1976
|
-
flexShrink: 0
|
|
1977
|
-
},
|
|
1978
2021
|
selectButton: (isCurrentPlan) => ({
|
|
1979
2022
|
width: "100%",
|
|
1980
2023
|
padding: "12px 24px",
|
|
@@ -1986,11 +2029,46 @@ var styles3 = {
|
|
|
1986
2029
|
fontWeight: 600,
|
|
1987
2030
|
cursor: isCurrentPlan ? "default" : "pointer",
|
|
1988
2031
|
transition: "background-color 0.15s"
|
|
2032
|
+
})
|
|
2033
|
+
};
|
|
2034
|
+
function PricingCard({
|
|
2035
|
+
plan,
|
|
2036
|
+
isCurrentPlan,
|
|
2037
|
+
isCheckoutPending,
|
|
2038
|
+
onSelect
|
|
2039
|
+
}) {
|
|
2040
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles4.card(isCurrentPlan), children: [
|
|
2041
|
+
isCurrentPlan && /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles4.currentBadge, children: "Current Plan" }),
|
|
2042
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: styles4.planName, children: plan.name }),
|
|
2043
|
+
plan.description && /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles4.planDescription, children: plan.description }),
|
|
2044
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles4.priceRow, children: [
|
|
2045
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: styles4.priceAmount, children: formatAmount(plan.amount, plan.currency) }),
|
|
2046
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: styles4.priceInterval, children: intervalLabels[plan.interval] })
|
|
2047
|
+
] }),
|
|
2048
|
+
plan.features && plan.features.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(PricingFeatureList, { features: plan.features }),
|
|
2049
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2050
|
+
"button",
|
|
2051
|
+
{
|
|
2052
|
+
type: "button",
|
|
2053
|
+
onClick: () => onSelect(plan),
|
|
2054
|
+
disabled: isCurrentPlan || isCheckoutPending,
|
|
2055
|
+
style: {
|
|
2056
|
+
...styles4.selectButton(isCurrentPlan),
|
|
2057
|
+
...isCheckoutPending && !isCurrentPlan ? { opacity: 0.6 } : {}
|
|
2058
|
+
},
|
|
2059
|
+
children: isCurrentPlan ? "Current Plan" : "Subscribe"
|
|
2060
|
+
}
|
|
2061
|
+
)
|
|
2062
|
+
] });
|
|
2063
|
+
}
|
|
2064
|
+
PricingCard.displayName = "PricingCard";
|
|
2065
|
+
var styles5 = {
|
|
2066
|
+
grid: (columns) => ({
|
|
2067
|
+
display: "grid",
|
|
2068
|
+
gridTemplateColumns: `repeat(${columns}, 1fr)`,
|
|
2069
|
+
gap: "24px",
|
|
2070
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'
|
|
1989
2071
|
}),
|
|
1990
|
-
skeleton: {
|
|
1991
|
-
backgroundColor: "#f3f4f6",
|
|
1992
|
-
borderRadius: "12px"
|
|
1993
|
-
},
|
|
1994
2072
|
skeletonCard: {
|
|
1995
2073
|
border: "1px solid #e5e7eb",
|
|
1996
2074
|
borderRadius: "12px",
|
|
@@ -2092,8 +2170,8 @@ function ProviderSelectModal({
|
|
|
2092
2170
|
onSelect,
|
|
2093
2171
|
onClose
|
|
2094
2172
|
}) {
|
|
2095
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { style:
|
|
2096
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style:
|
|
2173
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles5.overlay, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles5.modal, onClick: (e) => e.stopPropagation(), children: [
|
|
2174
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: styles5.modalTitle, children: "Select payment method" }),
|
|
2097
2175
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: providers.map((p) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2098
2176
|
"button",
|
|
2099
2177
|
{
|
|
@@ -2121,17 +2199,22 @@ function ProviderSelectModal({
|
|
|
2121
2199
|
},
|
|
2122
2200
|
p.provider
|
|
2123
2201
|
)) }),
|
|
2124
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style:
|
|
2202
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style: styles5.closeButton, onClick: onClose, children: "Cancel" })
|
|
2125
2203
|
] }) });
|
|
2126
2204
|
}
|
|
2205
|
+
var intervalLabels2 = {
|
|
2206
|
+
MONTHLY: "/mo",
|
|
2207
|
+
YEARLY: "/yr",
|
|
2208
|
+
ONE_TIME: ""
|
|
2209
|
+
};
|
|
2127
2210
|
function TransferModal({
|
|
2128
2211
|
data,
|
|
2129
2212
|
onClose
|
|
2130
2213
|
}) {
|
|
2131
2214
|
const bankDetails = data.bankDetails;
|
|
2132
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { style:
|
|
2133
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style:
|
|
2134
|
-
/* @__PURE__ */ jsxRuntime.jsxs("p", { style:
|
|
2215
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles5.overlay, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles5.modal, onClick: (e) => e.stopPropagation(), children: [
|
|
2216
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: styles5.modalTitle, children: "Manual Transfer" }),
|
|
2217
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: styles5.modalSubtitle, children: [
|
|
2135
2218
|
"Transfer the amount below to subscribe to",
|
|
2136
2219
|
" ",
|
|
2137
2220
|
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: data.plan?.name })
|
|
@@ -2148,7 +2231,7 @@ function TransferModal({
|
|
|
2148
2231
|
},
|
|
2149
2232
|
children: [
|
|
2150
2233
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "32px", fontWeight: 700, color: "#111827" }, children: data.plan ? formatAmount(data.plan.amount, data.plan.currency) : "" }),
|
|
2151
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "14px", color: "#6b7280" }, children: data.plan?.interval ?
|
|
2234
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "14px", color: "#6b7280" }, children: data.plan?.interval ? intervalLabels2[data.plan.interval] ?? "" : "" })
|
|
2152
2235
|
]
|
|
2153
2236
|
}
|
|
2154
2237
|
),
|
|
@@ -2165,12 +2248,12 @@ function TransferModal({
|
|
|
2165
2248
|
children: "Bank Details"
|
|
2166
2249
|
}
|
|
2167
2250
|
),
|
|
2168
|
-
Object.entries(bankDetails).filter(([, v]) => v).map(([key, value]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style:
|
|
2169
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style:
|
|
2170
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style:
|
|
2251
|
+
Object.entries(bankDetails).filter(([, v]) => v).map(([key, value]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles5.bankDetailRow, children: [
|
|
2252
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: styles5.bankDetailLabel, children: key.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase()) }),
|
|
2253
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: styles5.bankDetailValue, children: value })
|
|
2171
2254
|
] }, key))
|
|
2172
2255
|
] }),
|
|
2173
|
-
data.transferInstructions && /* @__PURE__ */ jsxRuntime.jsx("div", { style:
|
|
2256
|
+
data.transferInstructions && /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles5.instructions, children: data.transferInstructions }),
|
|
2174
2257
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2175
2258
|
"p",
|
|
2176
2259
|
{
|
|
@@ -2182,7 +2265,7 @@ function TransferModal({
|
|
|
2182
2265
|
children: "After completing the transfer, submit your proof of payment. Your subscription will be activated once the transfer is verified."
|
|
2183
2266
|
}
|
|
2184
2267
|
),
|
|
2185
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style:
|
|
2268
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style: styles5.closeButton, onClick: onClose, children: "Close" })
|
|
2186
2269
|
] }) });
|
|
2187
2270
|
}
|
|
2188
2271
|
function PricingTable({
|
|
@@ -2233,12 +2316,12 @@ function PricingTable({
|
|
|
2233
2316
|
checkout({ planId: plan.id, provider, successUrl, cancelUrl });
|
|
2234
2317
|
};
|
|
2235
2318
|
if (plansLoading) {
|
|
2236
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style: { ...
|
|
2319
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style: { ...styles5.grid(columns), ...style }, children: Array.from({ length: columns }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles5.skeletonCard, children: [
|
|
2237
2320
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2238
2321
|
"div",
|
|
2239
2322
|
{
|
|
2240
2323
|
style: {
|
|
2241
|
-
...
|
|
2324
|
+
...styles5.skeletonLine,
|
|
2242
2325
|
width: "60%",
|
|
2243
2326
|
height: "20px"
|
|
2244
2327
|
}
|
|
@@ -2248,7 +2331,7 @@ function PricingTable({
|
|
|
2248
2331
|
"div",
|
|
2249
2332
|
{
|
|
2250
2333
|
style: {
|
|
2251
|
-
...
|
|
2334
|
+
...styles5.skeletonLine,
|
|
2252
2335
|
width: "80%",
|
|
2253
2336
|
height: "14px"
|
|
2254
2337
|
}
|
|
@@ -2258,7 +2341,7 @@ function PricingTable({
|
|
|
2258
2341
|
"div",
|
|
2259
2342
|
{
|
|
2260
2343
|
style: {
|
|
2261
|
-
...
|
|
2344
|
+
...styles5.skeletonLine,
|
|
2262
2345
|
width: "40%",
|
|
2263
2346
|
height: "36px",
|
|
2264
2347
|
marginTop: "8px"
|
|
@@ -2269,7 +2352,7 @@ function PricingTable({
|
|
|
2269
2352
|
"div",
|
|
2270
2353
|
{
|
|
2271
2354
|
style: {
|
|
2272
|
-
...
|
|
2355
|
+
...styles5.skeletonLine,
|
|
2273
2356
|
width: "90%",
|
|
2274
2357
|
height: "14px"
|
|
2275
2358
|
}
|
|
@@ -2280,7 +2363,7 @@ function PricingTable({
|
|
|
2280
2363
|
"div",
|
|
2281
2364
|
{
|
|
2282
2365
|
style: {
|
|
2283
|
-
...
|
|
2366
|
+
...styles5.skeletonLine,
|
|
2284
2367
|
width: "100%",
|
|
2285
2368
|
height: "44px",
|
|
2286
2369
|
marginTop: "16px"
|
|
@@ -2295,35 +2378,19 @@ function PricingTable({
|
|
|
2295
2378
|
"div",
|
|
2296
2379
|
{
|
|
2297
2380
|
className,
|
|
2298
|
-
style: { ...
|
|
2381
|
+
style: { ...styles5.grid(columns), ...style },
|
|
2299
2382
|
children: sortedPlans.map((plan) => {
|
|
2300
2383
|
const isCurrentPlan = subscription?.planId === plan.id && subscription.status === "ACTIVE";
|
|
2301
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
plan.
|
|
2310
|
-
|
|
2311
|
-
feature
|
|
2312
|
-
] }, i)) }),
|
|
2313
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2314
|
-
"button",
|
|
2315
|
-
{
|
|
2316
|
-
type: "button",
|
|
2317
|
-
onClick: () => handleSelect(plan),
|
|
2318
|
-
disabled: isCurrentPlan || checkoutPending,
|
|
2319
|
-
style: {
|
|
2320
|
-
...styles3.selectButton(isCurrentPlan),
|
|
2321
|
-
...checkoutPending && !isCurrentPlan ? { opacity: 0.6 } : {}
|
|
2322
|
-
},
|
|
2323
|
-
children: isCurrentPlan ? "Current Plan" : "Subscribe"
|
|
2324
|
-
}
|
|
2325
|
-
)
|
|
2326
|
-
] }, plan.id);
|
|
2384
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2385
|
+
PricingCard,
|
|
2386
|
+
{
|
|
2387
|
+
plan,
|
|
2388
|
+
isCurrentPlan,
|
|
2389
|
+
isCheckoutPending: checkoutPending,
|
|
2390
|
+
onSelect: handleSelect
|
|
2391
|
+
},
|
|
2392
|
+
plan.id
|
|
2393
|
+
);
|
|
2327
2394
|
})
|
|
2328
2395
|
}
|
|
2329
2396
|
),
|
|
@@ -2409,126 +2476,62 @@ var PROVIDER_ICONS2 = {
|
|
|
2409
2476
|
NUVEI: "\u{1F4B3}",
|
|
2410
2477
|
MANUAL_TRANSFER: "\u{1F3E6}"
|
|
2411
2478
|
};
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
}
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
}
|
|
2467
|
-
|
|
2468
|
-
onProviderSelect?.(provider);
|
|
2469
|
-
checkout({
|
|
2470
|
-
planId,
|
|
2471
|
-
intentId,
|
|
2472
|
-
provider,
|
|
2473
|
-
successUrl,
|
|
2474
|
-
cancelUrl
|
|
2475
|
-
});
|
|
2476
|
-
};
|
|
2477
|
-
const isDisabled = disabled || isPending || providersLoading || !planId && !intentId;
|
|
2478
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2479
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2480
|
-
"button",
|
|
2481
|
-
{
|
|
2482
|
-
type: "button",
|
|
2483
|
-
className,
|
|
2484
|
-
style: {
|
|
2485
|
-
padding: "10px 24px",
|
|
2486
|
-
fontSize: "14px",
|
|
2487
|
-
fontWeight: 600,
|
|
2488
|
-
color: "#fff",
|
|
2489
|
-
backgroundColor: isDisabled ? "#9ca3af" : "#111827",
|
|
2490
|
-
border: "none",
|
|
2491
|
-
borderRadius: "8px",
|
|
2492
|
-
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
2493
|
-
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
2494
|
-
...style
|
|
2495
|
-
},
|
|
2496
|
-
onClick: handleClick,
|
|
2497
|
-
disabled: isDisabled,
|
|
2498
|
-
children: isPending ? billing?.processing ?? "Processing..." : children ?? (billing?.pay ?? "Pay")
|
|
2499
|
-
}
|
|
2500
|
-
),
|
|
2501
|
-
showProviderModal && providers && providers.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2502
|
-
ProviderModal,
|
|
2503
|
-
{
|
|
2504
|
-
providers,
|
|
2505
|
-
isPending,
|
|
2506
|
-
onSelect: doCheckout,
|
|
2507
|
-
onClose: () => setShowProviderModal(false),
|
|
2508
|
-
labels: billing
|
|
2509
|
-
}
|
|
2510
|
-
),
|
|
2511
|
-
showTransferModal && transferData && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2512
|
-
TransferModal2,
|
|
2513
|
-
{
|
|
2514
|
-
data: transferData,
|
|
2515
|
-
onClose: () => {
|
|
2516
|
-
setShowTransferModal(false);
|
|
2517
|
-
setTransferData(null);
|
|
2518
|
-
},
|
|
2519
|
-
labels: billing
|
|
2520
|
-
}
|
|
2521
|
-
),
|
|
2522
|
-
payphoneData?.widgetConfig && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2523
|
-
PayphoneModal,
|
|
2524
|
-
{
|
|
2525
|
-
config: payphoneData.widgetConfig,
|
|
2526
|
-
successUrl,
|
|
2527
|
-
onClose: () => setPayphoneData(null)
|
|
2528
|
-
}
|
|
2529
|
-
)
|
|
2530
|
-
] });
|
|
2531
|
-
}
|
|
2479
|
+
var modalStyles = {
|
|
2480
|
+
overlay: {
|
|
2481
|
+
position: "fixed",
|
|
2482
|
+
inset: 0,
|
|
2483
|
+
backgroundColor: "rgba(0,0,0,0.5)",
|
|
2484
|
+
display: "flex",
|
|
2485
|
+
alignItems: "center",
|
|
2486
|
+
justifyContent: "center",
|
|
2487
|
+
zIndex: 9999,
|
|
2488
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'
|
|
2489
|
+
},
|
|
2490
|
+
card: {
|
|
2491
|
+
backgroundColor: "#fff",
|
|
2492
|
+
borderRadius: "12px",
|
|
2493
|
+
padding: "24px",
|
|
2494
|
+
maxWidth: "420px",
|
|
2495
|
+
width: "90%",
|
|
2496
|
+
boxShadow: "0 25px 50px -12px rgba(0,0,0,0.25)"
|
|
2497
|
+
},
|
|
2498
|
+
title: {
|
|
2499
|
+
fontSize: "18px",
|
|
2500
|
+
fontWeight: 700,
|
|
2501
|
+
color: "#111827",
|
|
2502
|
+
margin: "0 0 20px 0",
|
|
2503
|
+
textAlign: "center"
|
|
2504
|
+
},
|
|
2505
|
+
providerButton: {
|
|
2506
|
+
display: "flex",
|
|
2507
|
+
alignItems: "center",
|
|
2508
|
+
width: "100%",
|
|
2509
|
+
padding: "12px 16px",
|
|
2510
|
+
border: "1px solid #e5e7eb",
|
|
2511
|
+
borderRadius: "8px",
|
|
2512
|
+
backgroundColor: "#fff",
|
|
2513
|
+
cursor: "pointer",
|
|
2514
|
+
fontSize: "14px",
|
|
2515
|
+
fontWeight: 500,
|
|
2516
|
+
color: "#111827",
|
|
2517
|
+
transition: "background-color 0.15s",
|
|
2518
|
+
fontFamily: "inherit"
|
|
2519
|
+
},
|
|
2520
|
+
cancelButton: {
|
|
2521
|
+
display: "block",
|
|
2522
|
+
width: "100%",
|
|
2523
|
+
marginTop: "16px",
|
|
2524
|
+
padding: "10px",
|
|
2525
|
+
border: "none",
|
|
2526
|
+
borderRadius: "8px",
|
|
2527
|
+
backgroundColor: "#f3f4f6",
|
|
2528
|
+
color: "#6b7280",
|
|
2529
|
+
fontSize: "14px",
|
|
2530
|
+
fontWeight: 500,
|
|
2531
|
+
cursor: "pointer",
|
|
2532
|
+
fontFamily: "inherit"
|
|
2533
|
+
}
|
|
2534
|
+
};
|
|
2532
2535
|
function ProviderModal({
|
|
2533
2536
|
providers,
|
|
2534
2537
|
isPending,
|
|
@@ -2566,7 +2569,7 @@ function TransferModal2({
|
|
|
2566
2569
|
const bankDetails = data.bankDetails;
|
|
2567
2570
|
const plan = data.plan;
|
|
2568
2571
|
const intent = data.intent;
|
|
2569
|
-
const displayAmount = plan ?
|
|
2572
|
+
const displayAmount = plan ? formatAmount(plan.amount, plan.currency) : intent ? formatAmount(intent.amount, intent.currency) : "";
|
|
2570
2573
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: modalStyles.overlay, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: modalStyles.card, onClick: (e) => e.stopPropagation(), children: [
|
|
2571
2574
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: modalStyles.title, children: labels?.bankTransfer ?? "Bank Transfer" }),
|
|
2572
2575
|
displayAmount && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -2646,62 +2649,114 @@ function TransferModal2({
|
|
|
2646
2649
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style: modalStyles.cancelButton, onClick: onClose, children: "Close" })
|
|
2647
2650
|
] }) });
|
|
2648
2651
|
}
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2652
|
+
function PayButton({
|
|
2653
|
+
planId,
|
|
2654
|
+
intentId,
|
|
2655
|
+
successUrl,
|
|
2656
|
+
cancelUrl,
|
|
2657
|
+
className,
|
|
2658
|
+
style,
|
|
2659
|
+
children,
|
|
2660
|
+
disabled,
|
|
2661
|
+
onSuccess,
|
|
2662
|
+
onError,
|
|
2663
|
+
onProviderSelect
|
|
2664
|
+
}) {
|
|
2665
|
+
const messages = useMessages();
|
|
2666
|
+
const billing = messages?.billing;
|
|
2667
|
+
const [showProviderModal, setShowProviderModal] = react.useState(false);
|
|
2668
|
+
const [showTransferModal, setShowTransferModal] = react.useState(false);
|
|
2669
|
+
const [transferData, setTransferData] = react.useState(null);
|
|
2670
|
+
const [payphoneData, setPayphoneData] = react.useState(null);
|
|
2671
|
+
const { data: providers, isLoading: providersLoading } = usePaymentProviders();
|
|
2672
|
+
const { checkout, isPending } = useCheckout({
|
|
2673
|
+
redirectOnSuccess: true,
|
|
2674
|
+
onSuccess: (data) => {
|
|
2675
|
+
if (data.provider === "MANUAL_TRANSFER") {
|
|
2676
|
+
setTransferData(data);
|
|
2677
|
+
setShowTransferModal(true);
|
|
2678
|
+
setShowProviderModal(false);
|
|
2679
|
+
} else if (data.provider === "PAYPHONE" && data.widgetConfig) {
|
|
2680
|
+
setPayphoneData(data);
|
|
2681
|
+
setShowProviderModal(false);
|
|
2682
|
+
}
|
|
2683
|
+
onSuccess?.(data);
|
|
2684
|
+
},
|
|
2685
|
+
onError
|
|
2686
|
+
});
|
|
2687
|
+
const handleClick = () => {
|
|
2688
|
+
if (!providers || providers.length === 0) return;
|
|
2689
|
+
if (providers.length === 1) {
|
|
2690
|
+
doCheckout(providers[0].provider);
|
|
2691
|
+
} else {
|
|
2692
|
+
setShowProviderModal(true);
|
|
2693
|
+
}
|
|
2694
|
+
};
|
|
2695
|
+
const doCheckout = (provider) => {
|
|
2696
|
+
onProviderSelect?.(provider);
|
|
2697
|
+
checkout({
|
|
2698
|
+
planId,
|
|
2699
|
+
intentId,
|
|
2700
|
+
provider,
|
|
2701
|
+
successUrl,
|
|
2702
|
+
cancelUrl
|
|
2703
|
+
});
|
|
2704
|
+
};
|
|
2705
|
+
const isDisabled = disabled || isPending || providersLoading || !planId && !intentId;
|
|
2706
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2707
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2708
|
+
"button",
|
|
2709
|
+
{
|
|
2710
|
+
type: "button",
|
|
2711
|
+
className,
|
|
2712
|
+
style: {
|
|
2713
|
+
padding: "10px 24px",
|
|
2714
|
+
fontSize: "14px",
|
|
2715
|
+
fontWeight: 600,
|
|
2716
|
+
color: "#fff",
|
|
2717
|
+
backgroundColor: isDisabled ? "#9ca3af" : "#111827",
|
|
2718
|
+
border: "none",
|
|
2719
|
+
borderRadius: "8px",
|
|
2720
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
2721
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
2722
|
+
...style
|
|
2723
|
+
},
|
|
2724
|
+
onClick: handleClick,
|
|
2725
|
+
disabled: isDisabled,
|
|
2726
|
+
children: isPending ? billing?.processing ?? "Processing..." : children ?? (billing?.pay ?? "Pay")
|
|
2727
|
+
}
|
|
2728
|
+
),
|
|
2729
|
+
showProviderModal && providers && providers.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2730
|
+
ProviderModal,
|
|
2731
|
+
{
|
|
2732
|
+
providers,
|
|
2733
|
+
isPending,
|
|
2734
|
+
onSelect: doCheckout,
|
|
2735
|
+
onClose: () => setShowProviderModal(false),
|
|
2736
|
+
labels: billing
|
|
2737
|
+
}
|
|
2738
|
+
),
|
|
2739
|
+
showTransferModal && transferData && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2740
|
+
TransferModal2,
|
|
2741
|
+
{
|
|
2742
|
+
data: transferData,
|
|
2743
|
+
onClose: () => {
|
|
2744
|
+
setShowTransferModal(false);
|
|
2745
|
+
setTransferData(null);
|
|
2746
|
+
},
|
|
2747
|
+
labels: billing
|
|
2748
|
+
}
|
|
2749
|
+
),
|
|
2750
|
+
payphoneData?.widgetConfig && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2751
|
+
PayphoneModal,
|
|
2752
|
+
{
|
|
2753
|
+
config: payphoneData.widgetConfig,
|
|
2754
|
+
successUrl,
|
|
2755
|
+
onClose: () => setPayphoneData(null)
|
|
2756
|
+
}
|
|
2757
|
+
)
|
|
2758
|
+
] });
|
|
2759
|
+
}
|
|
2705
2760
|
function usePayphoneConfirm(options) {
|
|
2706
2761
|
const client = useAccessClient();
|
|
2707
2762
|
return reactQuery.useMutation({
|
|
@@ -2767,7 +2822,7 @@ var statusConfig = {
|
|
|
2767
2822
|
UNPAID: { bg: "#fee2e2", color: "#991b1b", label: "Unpaid" },
|
|
2768
2823
|
INCOMPLETE: { bg: "#f3f4f6", color: "#6b7280", label: "Incomplete" }
|
|
2769
2824
|
};
|
|
2770
|
-
var
|
|
2825
|
+
var styles6 = {
|
|
2771
2826
|
badge: {
|
|
2772
2827
|
display: "inline-flex",
|
|
2773
2828
|
alignItems: "center",
|
|
@@ -2796,7 +2851,7 @@ var styles4 = {
|
|
|
2796
2851
|
function SubscriptionBadge({ className, style }) {
|
|
2797
2852
|
const { data: subscription, isLoading } = useSubscription();
|
|
2798
2853
|
if (isLoading) {
|
|
2799
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { className, style: { ...
|
|
2854
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className, style: { ...styles6.skeleton, ...style } });
|
|
2800
2855
|
}
|
|
2801
2856
|
if (!subscription) {
|
|
2802
2857
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2804,7 +2859,7 @@ function SubscriptionBadge({ className, style }) {
|
|
|
2804
2859
|
{
|
|
2805
2860
|
className,
|
|
2806
2861
|
style: {
|
|
2807
|
-
...
|
|
2862
|
+
...styles6.badge,
|
|
2808
2863
|
backgroundColor: "#f3f4f6",
|
|
2809
2864
|
color: "#6b7280",
|
|
2810
2865
|
...style
|
|
@@ -2819,13 +2874,13 @@ function SubscriptionBadge({ className, style }) {
|
|
|
2819
2874
|
{
|
|
2820
2875
|
className,
|
|
2821
2876
|
style: {
|
|
2822
|
-
...
|
|
2877
|
+
...styles6.badge,
|
|
2823
2878
|
backgroundColor: config.bg,
|
|
2824
2879
|
color: config.color,
|
|
2825
2880
|
...style
|
|
2826
2881
|
},
|
|
2827
2882
|
children: [
|
|
2828
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style:
|
|
2883
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: styles6.dot(config.color), "aria-hidden": "true" }),
|
|
2829
2884
|
subscription.plan.name,
|
|
2830
2885
|
" \xB7 ",
|
|
2831
2886
|
config.label
|
|
@@ -2859,19 +2914,7 @@ function formatDate2(dateStr) {
|
|
|
2859
2914
|
return dateStr;
|
|
2860
2915
|
}
|
|
2861
2916
|
}
|
|
2862
|
-
|
|
2863
|
-
try {
|
|
2864
|
-
return new Intl.NumberFormat(void 0, {
|
|
2865
|
-
style: "currency",
|
|
2866
|
-
currency,
|
|
2867
|
-
minimumFractionDigits: 0,
|
|
2868
|
-
maximumFractionDigits: 2
|
|
2869
|
-
}).format(amount / 100);
|
|
2870
|
-
} catch {
|
|
2871
|
-
return `${currency} ${(amount / 100).toFixed(2)}`;
|
|
2872
|
-
}
|
|
2873
|
-
}
|
|
2874
|
-
var styles5 = {
|
|
2917
|
+
var styles7 = {
|
|
2875
2918
|
container: {
|
|
2876
2919
|
border: "1px solid #e5e7eb",
|
|
2877
2920
|
borderRadius: "12px",
|
|
@@ -2940,41 +2983,41 @@ var styles5 = {
|
|
|
2940
2983
|
function InvoiceList({ className, style }) {
|
|
2941
2984
|
const { data: invoices, isLoading } = useInvoices();
|
|
2942
2985
|
if (isLoading) {
|
|
2943
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...
|
|
2944
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style:
|
|
2986
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...styles7.container, ...style }, children: [
|
|
2987
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: styles7.header, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...styles7.skeleton, width: "100px", height: "18px" } }) }),
|
|
2945
2988
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "24px" }, children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2946
2989
|
"div",
|
|
2947
2990
|
{
|
|
2948
|
-
style: { ...
|
|
2991
|
+
style: { ...styles7.skeleton, width: "100%", height: "16px", marginBottom: "16px" }
|
|
2949
2992
|
},
|
|
2950
2993
|
i
|
|
2951
2994
|
)) })
|
|
2952
2995
|
] });
|
|
2953
2996
|
}
|
|
2954
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...
|
|
2955
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style:
|
|
2956
|
-
/* @__PURE__ */ jsxRuntime.jsxs("table", { style:
|
|
2997
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...styles7.container, ...style }, children: [
|
|
2998
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: styles7.header, children: /* @__PURE__ */ jsxRuntime.jsx("h3", { style: styles7.title, children: "Invoices" }) }),
|
|
2999
|
+
/* @__PURE__ */ jsxRuntime.jsxs("table", { style: styles7.table, children: [
|
|
2957
3000
|
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2958
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style:
|
|
2959
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style:
|
|
2960
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style:
|
|
2961
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style:
|
|
3001
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: styles7.th, children: "Date" }),
|
|
3002
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: styles7.th, children: "Amount" }),
|
|
3003
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: styles7.th, children: "Status" }),
|
|
3004
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: styles7.th, children: "Invoice" })
|
|
2962
3005
|
] }) }),
|
|
2963
3006
|
/* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
|
|
2964
|
-
(!invoices || invoices.length === 0) && /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: 4, style:
|
|
3007
|
+
(!invoices || invoices.length === 0) && /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: 4, style: styles7.emptyRow, children: "No invoices yet." }) }),
|
|
2965
3008
|
invoices?.map((invoice) => {
|
|
2966
3009
|
const sc = statusColors2[invoice.status];
|
|
2967
3010
|
return /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2968
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { style:
|
|
2969
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { style:
|
|
2970
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { style:
|
|
2971
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { style:
|
|
3011
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: styles7.td, children: formatDate2(invoice.createdAt) }),
|
|
3012
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: styles7.td, children: formatAmount(invoice.amount, invoice.currency) }),
|
|
3013
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: styles7.td, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles7.badge(sc.bg, sc.color), children: invoice.status }) }),
|
|
3014
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: styles7.td, children: invoice.invoiceUrl ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2972
3015
|
"a",
|
|
2973
3016
|
{
|
|
2974
3017
|
href: invoice.invoiceUrl,
|
|
2975
3018
|
target: "_blank",
|
|
2976
3019
|
rel: "noopener noreferrer",
|
|
2977
|
-
style:
|
|
3020
|
+
style: styles7.link,
|
|
2978
3021
|
children: "View"
|
|
2979
3022
|
}
|
|
2980
3023
|
) : /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#d1d5db" }, children: "\u2014" }) })
|
|
@@ -3257,6 +3300,17 @@ function useSwitchTenant() {
|
|
|
3257
3300
|
};
|
|
3258
3301
|
return { switchTenant };
|
|
3259
3302
|
}
|
|
3303
|
+
function createMutationHook(config) {
|
|
3304
|
+
return function useGeneratedMutation(options) {
|
|
3305
|
+
const client = useAccessClient();
|
|
3306
|
+
return reactQuery.useMutation({
|
|
3307
|
+
mutationKey: config.mutationKey,
|
|
3308
|
+
mutationFn: (input) => config.mutationFn(client, input),
|
|
3309
|
+
onSuccess: options?.onSuccess,
|
|
3310
|
+
onError: options?.onError
|
|
3311
|
+
});
|
|
3312
|
+
};
|
|
3313
|
+
}
|
|
3260
3314
|
function zodToFieldErrors(zodError) {
|
|
3261
3315
|
return zodError.issues.map((issue) => ({
|
|
3262
3316
|
field: issue.path.join("."),
|
|
@@ -3313,7 +3367,7 @@ function usePasswordToggle() {
|
|
|
3313
3367
|
}
|
|
3314
3368
|
|
|
3315
3369
|
// src/index.ts
|
|
3316
|
-
var SDK_VERSION = "0.
|
|
3370
|
+
var SDK_VERSION = "0.8.0";
|
|
3317
3371
|
|
|
3318
3372
|
exports.AziridProvider = AziridProvider;
|
|
3319
3373
|
exports.BASE_PATHS = BASE_PATHS;
|
|
@@ -3334,6 +3388,7 @@ exports.changePasswordSchema = changePasswordSchema;
|
|
|
3334
3388
|
exports.cn = cn;
|
|
3335
3389
|
exports.createAccessClient = createAccessClient;
|
|
3336
3390
|
exports.createLoginSchema = createLoginSchema;
|
|
3391
|
+
exports.createMutationHook = createMutationHook;
|
|
3337
3392
|
exports.createSignupSchema = createSignupSchema;
|
|
3338
3393
|
exports.en = en;
|
|
3339
3394
|
exports.es = es;
|