azirid-react 0.6.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.js CHANGED
@@ -95,7 +95,8 @@ var SUFFIXES = {
95
95
  transferProofs: "billing/transfer-proofs",
96
96
  payphoneConfirm: "billing/payphone/confirm",
97
97
  referralMe: "referrals/me",
98
- referralStats: "referrals/stats"
98
+ referralStats: "referrals/stats",
99
+ userTenants: "tenants"
99
100
  };
100
101
  var BASE_PATHS = {
101
102
  /** Proxy mode (Next.js): requests go to the same origin via route handler */
@@ -159,7 +160,7 @@ function createAccessClient(config, appContext) {
159
160
  return match ? decodeURIComponent(match[1]) : null;
160
161
  }
161
162
  const sessionPaths = [paths.refresh, paths.bootstrap, paths.logout];
162
- async function refreshTokensInternal() {
163
+ async function refreshTokensInternal(opts) {
163
164
  const reqHeaders = {
164
165
  "Content-Type": "application/json",
165
166
  ...config.headers
@@ -173,6 +174,9 @@ function createAccessClient(config, appContext) {
173
174
  if (refreshToken) {
174
175
  bodyPayload["rt"] = refreshToken;
175
176
  }
177
+ if (opts?.tenantId) {
178
+ bodyPayload["tenantId"] = opts.tenantId;
179
+ }
176
180
  const res = await fetch(`${baseUrl}${paths.refresh}`, {
177
181
  method: "POST",
178
182
  headers: reqHeaders,
@@ -193,7 +197,11 @@ function createAccessClient(config, appContext) {
193
197
  if (rt) setRefreshToken(rt);
194
198
  if (xc) setCsrfToken(xc);
195
199
  }
196
- function refreshTokens() {
200
+ function refreshTokens(opts) {
201
+ if (opts?.tenantId) {
202
+ return refreshTokensInternal(opts).finally(() => {
203
+ });
204
+ }
197
205
  if (refreshPromise) return refreshPromise;
198
206
  refreshPromise = refreshTokensInternal().finally(() => {
199
207
  refreshPromise = null;
@@ -301,7 +309,7 @@ function createAccessClient(config, appContext) {
301
309
  getRefreshToken,
302
310
  setCsrfToken,
303
311
  getCsrfToken,
304
- refreshSession: refreshTokens
312
+ refreshSession: (opts) => refreshTokens(opts)
305
313
  };
306
314
  }
307
315
 
@@ -503,6 +511,86 @@ function removeStyles() {
503
511
  document.getElementById(STYLE_ID)?.remove();
504
512
  injected = false;
505
513
  }
514
+ function useAuthMutations(deps) {
515
+ const {
516
+ client,
517
+ props,
518
+ setUser,
519
+ setError,
520
+ updateAccessToken,
521
+ saveSessionTokens,
522
+ normalizeToken,
523
+ withAppContext,
524
+ clearSession
525
+ } = deps;
526
+ const queryClient = useQueryClient();
527
+ const loginMutation = useMutation({
528
+ mutationFn: (data) => client.post(client.paths.login, withAppContext(data)),
529
+ onSuccess: (data) => {
530
+ setUser(data.user);
531
+ updateAccessToken(normalizeToken(data));
532
+ saveSessionTokens(data);
533
+ setError(null);
534
+ props.onLoginSuccess?.(data);
535
+ },
536
+ onError: (err) => {
537
+ setError(err.message);
538
+ props.onError?.(err.message);
539
+ }
540
+ });
541
+ const signupMutation = useMutation({
542
+ mutationFn: (data) => {
543
+ const { confirmPassword: _, ...payload } = data;
544
+ return client.post(client.paths.signup, withAppContext({ ...payload }));
545
+ },
546
+ onSuccess: (data) => {
547
+ setUser(data.user);
548
+ updateAccessToken(normalizeToken(data));
549
+ saveSessionTokens(data);
550
+ setError(null);
551
+ props.onSignupSuccess?.(data);
552
+ },
553
+ onError: (err) => {
554
+ setError(err.message);
555
+ props.onError?.(err.message);
556
+ }
557
+ });
558
+ const logoutMutation = useMutation({
559
+ mutationFn: () => client.post(client.paths.logout),
560
+ onSettled: () => {
561
+ clearSession();
562
+ setError(null);
563
+ queryClient.clear();
564
+ props.onLogoutSuccess?.();
565
+ }
566
+ });
567
+ const refreshFn = useCallback(async () => {
568
+ try {
569
+ await client.refreshSession();
570
+ updateAccessToken(client.getAccessToken());
571
+ } catch (err) {
572
+ clearSession();
573
+ queryClient.clear();
574
+ props.onSessionExpired?.();
575
+ throw err;
576
+ }
577
+ }, [client, queryClient, props, updateAccessToken, clearSession]);
578
+ const switchTenantFn = useCallback(
579
+ async (tenantId) => {
580
+ await client.refreshSession({ tenantId });
581
+ updateAccessToken(client.getAccessToken());
582
+ await queryClient.invalidateQueries({ queryKey: ["azirid-access"] });
583
+ },
584
+ [client, queryClient, updateAccessToken]
585
+ );
586
+ return {
587
+ loginMutation,
588
+ signupMutation,
589
+ logoutMutation,
590
+ refreshFn,
591
+ switchTenantFn
592
+ };
593
+ }
506
594
  var AziridContext = createContext(null);
507
595
  AziridContext.displayName = "AziridContext";
508
596
  var ClientContext = createContext(null);
@@ -535,7 +623,6 @@ function AziridProviderInner({
535
623
  client,
536
624
  props
537
625
  }) {
538
- const queryClient = useQueryClient();
539
626
  const [user, setUser] = useState(null);
540
627
  const [accessToken, setAccessToken] = useState(null);
541
628
  const [error, setError] = useState(null);
@@ -673,57 +760,23 @@ function AziridProviderInner({
673
760
  (data) => data.at ?? data.accessToken,
674
761
  []
675
762
  );
676
- const loginMutation = useMutation({
677
- mutationFn: (data) => client.post(client.paths.login, withAppContext(data)),
678
- onSuccess: (data) => {
679
- setUser(data.user);
680
- updateAccessToken(normalizeToken(data));
681
- saveSessionTokens(data);
682
- setError(null);
683
- props.onLoginSuccess?.(data);
684
- },
685
- onError: (err) => {
686
- setError(err.message);
687
- props.onError?.(err.message);
688
- }
689
- });
690
- const signupMutation = useMutation({
691
- mutationFn: (data) => {
692
- const { confirmPassword: _, ...payload } = data;
693
- return client.post(client.paths.signup, withAppContext({ ...payload }));
694
- },
695
- onSuccess: (data) => {
696
- setUser(data.user);
697
- updateAccessToken(normalizeToken(data));
698
- saveSessionTokens(data);
699
- setError(null);
700
- props.onSignupSuccess?.(data);
701
- },
702
- onError: (err) => {
703
- setError(err.message);
704
- props.onError?.(err.message);
705
- }
706
- });
707
- const logoutMutation = useMutation({
708
- mutationFn: () => client.post(client.paths.logout),
709
- onSettled: () => {
710
- clearSession();
711
- setError(null);
712
- queryClient.clear();
713
- props.onLogoutSuccess?.();
714
- }
763
+ const {
764
+ loginMutation,
765
+ signupMutation,
766
+ logoutMutation,
767
+ refreshFn,
768
+ switchTenantFn
769
+ } = useAuthMutations({
770
+ client,
771
+ props,
772
+ setUser,
773
+ setError,
774
+ updateAccessToken,
775
+ saveSessionTokens,
776
+ normalizeToken,
777
+ withAppContext,
778
+ clearSession
715
779
  });
716
- const refreshFn = useCallback(async () => {
717
- try {
718
- await client.refreshSession();
719
- updateAccessToken(client.getAccessToken());
720
- } catch (err) {
721
- clearSession();
722
- queryClient.clear();
723
- props.onSessionExpired?.();
724
- throw err;
725
- }
726
- }, [client, queryClient, props, updateAccessToken, clearSession]);
727
780
  const login = useCallback(
728
781
  (data) => loginMutation.mutate(data),
729
782
  [loginMutation]
@@ -746,6 +799,7 @@ function AziridProviderInner({
746
799
  logout,
747
800
  clearError,
748
801
  refresh: refreshFn,
802
+ switchTenant: switchTenantFn,
749
803
  setUser: setUserFn,
750
804
  isLoginPending: loginMutation.isPending,
751
805
  isSignupPending: signupMutation.isPending,
@@ -763,6 +817,7 @@ function AziridProviderInner({
763
817
  logout,
764
818
  clearError,
765
819
  refreshFn,
820
+ switchTenantFn,
766
821
  setUserFn,
767
822
  loginMutation,
768
823
  signupMutation,
@@ -1696,6 +1751,20 @@ function ReferralStats({ className, style }) {
1696
1751
  ] });
1697
1752
  }
1698
1753
  ReferralStats.displayName = "ReferralStats";
1754
+
1755
+ // ../shared/dist/index.js
1756
+ function formatAmount(amount, currency) {
1757
+ try {
1758
+ return new Intl.NumberFormat(void 0, {
1759
+ style: "currency",
1760
+ currency,
1761
+ minimumFractionDigits: 0,
1762
+ maximumFractionDigits: 2
1763
+ }).format(amount / 100);
1764
+ } catch {
1765
+ return `${currency} ${(amount / 100).toFixed(2)}`;
1766
+ }
1767
+ }
1699
1768
  function usePlans() {
1700
1769
  const client = useAccessClient();
1701
1770
  return useQuery({
@@ -1861,30 +1930,42 @@ var cancelStyle = {
1861
1930
  cursor: "pointer",
1862
1931
  fontFamily: "inherit"
1863
1932
  };
1933
+ var styles3 = {
1934
+ featuresList: {
1935
+ listStyle: "none",
1936
+ padding: 0,
1937
+ margin: "0 0 24px 0",
1938
+ flex: 1
1939
+ },
1940
+ featureItem: {
1941
+ display: "flex",
1942
+ alignItems: "center",
1943
+ gap: "8px",
1944
+ padding: "6px 0",
1945
+ fontSize: "14px",
1946
+ color: "#374151"
1947
+ },
1948
+ checkmark: {
1949
+ color: "#10b981",
1950
+ fontSize: "16px",
1951
+ fontWeight: 700,
1952
+ flexShrink: 0
1953
+ }
1954
+ };
1955
+ function PricingFeatureList({ features }) {
1956
+ if (!features || features.length === 0) return null;
1957
+ return /* @__PURE__ */ jsx("ul", { style: styles3.featuresList, children: features.map((feature, i) => /* @__PURE__ */ jsxs("li", { style: styles3.featureItem, children: [
1958
+ /* @__PURE__ */ jsx("span", { style: styles3.checkmark, "aria-hidden": "true", children: "\u2713" }),
1959
+ feature
1960
+ ] }, i)) });
1961
+ }
1962
+ PricingFeatureList.displayName = "PricingFeatureList";
1864
1963
  var intervalLabels = {
1865
1964
  MONTHLY: "/mo",
1866
1965
  YEARLY: "/yr",
1867
1966
  ONE_TIME: ""
1868
1967
  };
1869
- function formatAmount(amount, currency) {
1870
- try {
1871
- return new Intl.NumberFormat(void 0, {
1872
- style: "currency",
1873
- currency,
1874
- minimumFractionDigits: 0,
1875
- maximumFractionDigits: 2
1876
- }).format(amount / 100);
1877
- } catch {
1878
- return `${currency} ${(amount / 100).toFixed(2)}`;
1879
- }
1880
- }
1881
- var styles3 = {
1882
- grid: (columns) => ({
1883
- display: "grid",
1884
- gridTemplateColumns: `repeat(${columns}, 1fr)`,
1885
- gap: "24px",
1886
- fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'
1887
- }),
1968
+ var styles4 = {
1888
1969
  card: (isCurrentPlan) => ({
1889
1970
  border: isCurrentPlan ? "2px solid #6366f1" : "1px solid #e5e7eb",
1890
1971
  borderRadius: "12px",
@@ -1935,26 +2016,6 @@ var styles3 = {
1935
2016
  fontSize: "16px",
1936
2017
  color: "#6b7280"
1937
2018
  },
1938
- featuresList: {
1939
- listStyle: "none",
1940
- padding: 0,
1941
- margin: "0 0 24px 0",
1942
- flex: 1
1943
- },
1944
- featureItem: {
1945
- display: "flex",
1946
- alignItems: "center",
1947
- gap: "8px",
1948
- padding: "6px 0",
1949
- fontSize: "14px",
1950
- color: "#374151"
1951
- },
1952
- checkmark: {
1953
- color: "#10b981",
1954
- fontSize: "16px",
1955
- fontWeight: 700,
1956
- flexShrink: 0
1957
- },
1958
2019
  selectButton: (isCurrentPlan) => ({
1959
2020
  width: "100%",
1960
2021
  padding: "12px 24px",
@@ -1966,11 +2027,46 @@ var styles3 = {
1966
2027
  fontWeight: 600,
1967
2028
  cursor: isCurrentPlan ? "default" : "pointer",
1968
2029
  transition: "background-color 0.15s"
2030
+ })
2031
+ };
2032
+ function PricingCard({
2033
+ plan,
2034
+ isCurrentPlan,
2035
+ isCheckoutPending,
2036
+ onSelect
2037
+ }) {
2038
+ return /* @__PURE__ */ jsxs("div", { style: styles4.card(isCurrentPlan), children: [
2039
+ isCurrentPlan && /* @__PURE__ */ jsx("span", { style: styles4.currentBadge, children: "Current Plan" }),
2040
+ /* @__PURE__ */ jsx("h3", { style: styles4.planName, children: plan.name }),
2041
+ plan.description && /* @__PURE__ */ jsx("p", { style: styles4.planDescription, children: plan.description }),
2042
+ /* @__PURE__ */ jsxs("div", { style: styles4.priceRow, children: [
2043
+ /* @__PURE__ */ jsx("span", { style: styles4.priceAmount, children: formatAmount(plan.amount, plan.currency) }),
2044
+ /* @__PURE__ */ jsx("span", { style: styles4.priceInterval, children: intervalLabels[plan.interval] })
2045
+ ] }),
2046
+ plan.features && plan.features.length > 0 && /* @__PURE__ */ jsx(PricingFeatureList, { features: plan.features }),
2047
+ /* @__PURE__ */ jsx(
2048
+ "button",
2049
+ {
2050
+ type: "button",
2051
+ onClick: () => onSelect(plan),
2052
+ disabled: isCurrentPlan || isCheckoutPending,
2053
+ style: {
2054
+ ...styles4.selectButton(isCurrentPlan),
2055
+ ...isCheckoutPending && !isCurrentPlan ? { opacity: 0.6 } : {}
2056
+ },
2057
+ children: isCurrentPlan ? "Current Plan" : "Subscribe"
2058
+ }
2059
+ )
2060
+ ] });
2061
+ }
2062
+ PricingCard.displayName = "PricingCard";
2063
+ var styles5 = {
2064
+ grid: (columns) => ({
2065
+ display: "grid",
2066
+ gridTemplateColumns: `repeat(${columns}, 1fr)`,
2067
+ gap: "24px",
2068
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'
1969
2069
  }),
1970
- skeleton: {
1971
- backgroundColor: "#f3f4f6",
1972
- borderRadius: "12px"
1973
- },
1974
2070
  skeletonCard: {
1975
2071
  border: "1px solid #e5e7eb",
1976
2072
  borderRadius: "12px",
@@ -2072,8 +2168,8 @@ function ProviderSelectModal({
2072
2168
  onSelect,
2073
2169
  onClose
2074
2170
  }) {
2075
- return /* @__PURE__ */ jsx("div", { style: styles3.overlay, onClick: onClose, children: /* @__PURE__ */ jsxs("div", { style: styles3.modal, onClick: (e) => e.stopPropagation(), children: [
2076
- /* @__PURE__ */ jsx("h2", { style: styles3.modalTitle, children: "Select payment method" }),
2171
+ return /* @__PURE__ */ jsx("div", { style: styles5.overlay, onClick: onClose, children: /* @__PURE__ */ jsxs("div", { style: styles5.modal, onClick: (e) => e.stopPropagation(), children: [
2172
+ /* @__PURE__ */ jsx("h2", { style: styles5.modalTitle, children: "Select payment method" }),
2077
2173
  /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: providers.map((p) => /* @__PURE__ */ jsxs(
2078
2174
  "button",
2079
2175
  {
@@ -2101,17 +2197,22 @@ function ProviderSelectModal({
2101
2197
  },
2102
2198
  p.provider
2103
2199
  )) }),
2104
- /* @__PURE__ */ jsx("button", { type: "button", style: styles3.closeButton, onClick: onClose, children: "Cancel" })
2200
+ /* @__PURE__ */ jsx("button", { type: "button", style: styles5.closeButton, onClick: onClose, children: "Cancel" })
2105
2201
  ] }) });
2106
2202
  }
2203
+ var intervalLabels2 = {
2204
+ MONTHLY: "/mo",
2205
+ YEARLY: "/yr",
2206
+ ONE_TIME: ""
2207
+ };
2107
2208
  function TransferModal({
2108
2209
  data,
2109
2210
  onClose
2110
2211
  }) {
2111
2212
  const bankDetails = data.bankDetails;
2112
- return /* @__PURE__ */ jsx("div", { style: styles3.overlay, onClick: onClose, children: /* @__PURE__ */ jsxs("div", { style: styles3.modal, onClick: (e) => e.stopPropagation(), children: [
2113
- /* @__PURE__ */ jsx("h2", { style: styles3.modalTitle, children: "Manual Transfer" }),
2114
- /* @__PURE__ */ jsxs("p", { style: styles3.modalSubtitle, children: [
2213
+ return /* @__PURE__ */ jsx("div", { style: styles5.overlay, onClick: onClose, children: /* @__PURE__ */ jsxs("div", { style: styles5.modal, onClick: (e) => e.stopPropagation(), children: [
2214
+ /* @__PURE__ */ jsx("h2", { style: styles5.modalTitle, children: "Manual Transfer" }),
2215
+ /* @__PURE__ */ jsxs("p", { style: styles5.modalSubtitle, children: [
2115
2216
  "Transfer the amount below to subscribe to",
2116
2217
  " ",
2117
2218
  /* @__PURE__ */ jsx("strong", { children: data.plan?.name })
@@ -2128,7 +2229,7 @@ function TransferModal({
2128
2229
  },
2129
2230
  children: [
2130
2231
  /* @__PURE__ */ jsx("div", { style: { fontSize: "32px", fontWeight: 700, color: "#111827" }, children: data.plan ? formatAmount(data.plan.amount, data.plan.currency) : "" }),
2131
- /* @__PURE__ */ jsx("div", { style: { fontSize: "14px", color: "#6b7280" }, children: data.plan?.interval ? intervalLabels[data.plan.interval] ?? "" : "" })
2232
+ /* @__PURE__ */ jsx("div", { style: { fontSize: "14px", color: "#6b7280" }, children: data.plan?.interval ? intervalLabels2[data.plan.interval] ?? "" : "" })
2132
2233
  ]
2133
2234
  }
2134
2235
  ),
@@ -2145,12 +2246,12 @@ function TransferModal({
2145
2246
  children: "Bank Details"
2146
2247
  }
2147
2248
  ),
2148
- Object.entries(bankDetails).filter(([, v]) => v).map(([key, value]) => /* @__PURE__ */ jsxs("div", { style: styles3.bankDetailRow, children: [
2149
- /* @__PURE__ */ jsx("span", { style: styles3.bankDetailLabel, children: key.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase()) }),
2150
- /* @__PURE__ */ jsx("span", { style: styles3.bankDetailValue, children: value })
2249
+ Object.entries(bankDetails).filter(([, v]) => v).map(([key, value]) => /* @__PURE__ */ jsxs("div", { style: styles5.bankDetailRow, children: [
2250
+ /* @__PURE__ */ jsx("span", { style: styles5.bankDetailLabel, children: key.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase()) }),
2251
+ /* @__PURE__ */ jsx("span", { style: styles5.bankDetailValue, children: value })
2151
2252
  ] }, key))
2152
2253
  ] }),
2153
- data.transferInstructions && /* @__PURE__ */ jsx("div", { style: styles3.instructions, children: data.transferInstructions }),
2254
+ data.transferInstructions && /* @__PURE__ */ jsx("div", { style: styles5.instructions, children: data.transferInstructions }),
2154
2255
  /* @__PURE__ */ jsx(
2155
2256
  "p",
2156
2257
  {
@@ -2162,7 +2263,7 @@ function TransferModal({
2162
2263
  children: "After completing the transfer, submit your proof of payment. Your subscription will be activated once the transfer is verified."
2163
2264
  }
2164
2265
  ),
2165
- /* @__PURE__ */ jsx("button", { type: "button", style: styles3.closeButton, onClick: onClose, children: "Close" })
2266
+ /* @__PURE__ */ jsx("button", { type: "button", style: styles5.closeButton, onClick: onClose, children: "Close" })
2166
2267
  ] }) });
2167
2268
  }
2168
2269
  function PricingTable({
@@ -2213,12 +2314,12 @@ function PricingTable({
2213
2314
  checkout({ planId: plan.id, provider, successUrl, cancelUrl });
2214
2315
  };
2215
2316
  if (plansLoading) {
2216
- return /* @__PURE__ */ jsx("div", { className, style: { ...styles3.grid(columns), ...style }, children: Array.from({ length: columns }).map((_, i) => /* @__PURE__ */ jsxs("div", { style: styles3.skeletonCard, children: [
2317
+ return /* @__PURE__ */ jsx("div", { className, style: { ...styles5.grid(columns), ...style }, children: Array.from({ length: columns }).map((_, i) => /* @__PURE__ */ jsxs("div", { style: styles5.skeletonCard, children: [
2217
2318
  /* @__PURE__ */ jsx(
2218
2319
  "div",
2219
2320
  {
2220
2321
  style: {
2221
- ...styles3.skeletonLine,
2322
+ ...styles5.skeletonLine,
2222
2323
  width: "60%",
2223
2324
  height: "20px"
2224
2325
  }
@@ -2228,7 +2329,7 @@ function PricingTable({
2228
2329
  "div",
2229
2330
  {
2230
2331
  style: {
2231
- ...styles3.skeletonLine,
2332
+ ...styles5.skeletonLine,
2232
2333
  width: "80%",
2233
2334
  height: "14px"
2234
2335
  }
@@ -2238,7 +2339,7 @@ function PricingTable({
2238
2339
  "div",
2239
2340
  {
2240
2341
  style: {
2241
- ...styles3.skeletonLine,
2342
+ ...styles5.skeletonLine,
2242
2343
  width: "40%",
2243
2344
  height: "36px",
2244
2345
  marginTop: "8px"
@@ -2249,7 +2350,7 @@ function PricingTable({
2249
2350
  "div",
2250
2351
  {
2251
2352
  style: {
2252
- ...styles3.skeletonLine,
2353
+ ...styles5.skeletonLine,
2253
2354
  width: "90%",
2254
2355
  height: "14px"
2255
2356
  }
@@ -2260,7 +2361,7 @@ function PricingTable({
2260
2361
  "div",
2261
2362
  {
2262
2363
  style: {
2263
- ...styles3.skeletonLine,
2364
+ ...styles5.skeletonLine,
2264
2365
  width: "100%",
2265
2366
  height: "44px",
2266
2367
  marginTop: "16px"
@@ -2275,35 +2376,19 @@ function PricingTable({
2275
2376
  "div",
2276
2377
  {
2277
2378
  className,
2278
- style: { ...styles3.grid(columns), ...style },
2379
+ style: { ...styles5.grid(columns), ...style },
2279
2380
  children: sortedPlans.map((plan) => {
2280
2381
  const isCurrentPlan = subscription?.planId === plan.id && subscription.status === "ACTIVE";
2281
- return /* @__PURE__ */ jsxs("div", { style: styles3.card(isCurrentPlan), children: [
2282
- isCurrentPlan && /* @__PURE__ */ jsx("span", { style: styles3.currentBadge, children: "Current Plan" }),
2283
- /* @__PURE__ */ jsx("h3", { style: styles3.planName, children: plan.name }),
2284
- plan.description && /* @__PURE__ */ jsx("p", { style: styles3.planDescription, children: plan.description }),
2285
- /* @__PURE__ */ jsxs("div", { style: styles3.priceRow, children: [
2286
- /* @__PURE__ */ jsx("span", { style: styles3.priceAmount, children: formatAmount(plan.amount, plan.currency) }),
2287
- /* @__PURE__ */ jsx("span", { style: styles3.priceInterval, children: intervalLabels[plan.interval] })
2288
- ] }),
2289
- plan.features && plan.features.length > 0 && /* @__PURE__ */ jsx("ul", { style: styles3.featuresList, children: plan.features.map((feature, i) => /* @__PURE__ */ jsxs("li", { style: styles3.featureItem, children: [
2290
- /* @__PURE__ */ jsx("span", { style: styles3.checkmark, "aria-hidden": "true", children: "\u2713" }),
2291
- feature
2292
- ] }, i)) }),
2293
- /* @__PURE__ */ jsx(
2294
- "button",
2295
- {
2296
- type: "button",
2297
- onClick: () => handleSelect(plan),
2298
- disabled: isCurrentPlan || checkoutPending,
2299
- style: {
2300
- ...styles3.selectButton(isCurrentPlan),
2301
- ...checkoutPending && !isCurrentPlan ? { opacity: 0.6 } : {}
2302
- },
2303
- children: isCurrentPlan ? "Current Plan" : "Subscribe"
2304
- }
2305
- )
2306
- ] }, plan.id);
2382
+ return /* @__PURE__ */ jsx(
2383
+ PricingCard,
2384
+ {
2385
+ plan,
2386
+ isCurrentPlan,
2387
+ isCheckoutPending: checkoutPending,
2388
+ onSelect: handleSelect
2389
+ },
2390
+ plan.id
2391
+ );
2307
2392
  })
2308
2393
  }
2309
2394
  ),
@@ -2389,126 +2474,62 @@ var PROVIDER_ICONS2 = {
2389
2474
  NUVEI: "\u{1F4B3}",
2390
2475
  MANUAL_TRANSFER: "\u{1F3E6}"
2391
2476
  };
2392
- function formatAmount2(amount, currency) {
2393
- try {
2394
- return new Intl.NumberFormat(void 0, {
2395
- style: "currency",
2396
- currency,
2397
- minimumFractionDigits: 0,
2398
- maximumFractionDigits: 2
2399
- }).format(amount / 100);
2400
- } catch {
2401
- return `${currency} ${(amount / 100).toFixed(2)}`;
2402
- }
2403
- }
2404
- function PayButton({
2405
- planId,
2406
- intentId,
2407
- successUrl,
2408
- cancelUrl,
2409
- className,
2410
- style,
2411
- children,
2412
- disabled,
2413
- onSuccess,
2414
- onError,
2415
- onProviderSelect
2416
- }) {
2417
- const messages = useMessages();
2418
- const billing = messages?.billing;
2419
- const [showProviderModal, setShowProviderModal] = useState(false);
2420
- const [showTransferModal, setShowTransferModal] = useState(false);
2421
- const [transferData, setTransferData] = useState(null);
2422
- const [payphoneData, setPayphoneData] = useState(null);
2423
- const { data: providers, isLoading: providersLoading } = usePaymentProviders();
2424
- const { checkout, isPending } = useCheckout({
2425
- redirectOnSuccess: true,
2426
- onSuccess: (data) => {
2427
- if (data.provider === "MANUAL_TRANSFER") {
2428
- setTransferData(data);
2429
- setShowTransferModal(true);
2430
- setShowProviderModal(false);
2431
- } else if (data.provider === "PAYPHONE" && data.widgetConfig) {
2432
- setPayphoneData(data);
2433
- setShowProviderModal(false);
2434
- }
2435
- onSuccess?.(data);
2436
- },
2437
- onError
2438
- });
2439
- const handleClick = () => {
2440
- if (!providers || providers.length === 0) return;
2441
- if (providers.length === 1) {
2442
- doCheckout(providers[0].provider);
2443
- } else {
2444
- setShowProviderModal(true);
2445
- }
2446
- };
2447
- const doCheckout = (provider) => {
2448
- onProviderSelect?.(provider);
2449
- checkout({
2450
- planId,
2451
- intentId,
2452
- provider,
2453
- successUrl,
2454
- cancelUrl
2455
- });
2456
- };
2457
- const isDisabled = disabled || isPending || providersLoading || !planId && !intentId;
2458
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2459
- /* @__PURE__ */ jsx(
2460
- "button",
2461
- {
2462
- type: "button",
2463
- className,
2464
- style: {
2465
- padding: "10px 24px",
2466
- fontSize: "14px",
2467
- fontWeight: 600,
2468
- color: "#fff",
2469
- backgroundColor: isDisabled ? "#9ca3af" : "#111827",
2470
- border: "none",
2471
- borderRadius: "8px",
2472
- cursor: isDisabled ? "not-allowed" : "pointer",
2473
- fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
2474
- ...style
2475
- },
2476
- onClick: handleClick,
2477
- disabled: isDisabled,
2478
- children: isPending ? billing?.processing ?? "Processing..." : children ?? (billing?.pay ?? "Pay")
2479
- }
2480
- ),
2481
- showProviderModal && providers && providers.length > 1 && /* @__PURE__ */ jsx(
2482
- ProviderModal,
2483
- {
2484
- providers,
2485
- isPending,
2486
- onSelect: doCheckout,
2487
- onClose: () => setShowProviderModal(false),
2488
- labels: billing
2489
- }
2490
- ),
2491
- showTransferModal && transferData && /* @__PURE__ */ jsx(
2492
- TransferModal2,
2493
- {
2494
- data: transferData,
2495
- onClose: () => {
2496
- setShowTransferModal(false);
2497
- setTransferData(null);
2498
- },
2499
- labels: billing
2500
- }
2501
- ),
2502
- payphoneData?.widgetConfig && /* @__PURE__ */ jsx(
2503
- PayphoneModal,
2504
- {
2505
- config: payphoneData.widgetConfig,
2506
- successUrl,
2507
- onClose: () => setPayphoneData(null)
2508
- }
2509
- )
2510
- ] });
2511
- }
2477
+ var modalStyles = {
2478
+ overlay: {
2479
+ position: "fixed",
2480
+ inset: 0,
2481
+ backgroundColor: "rgba(0,0,0,0.5)",
2482
+ display: "flex",
2483
+ alignItems: "center",
2484
+ justifyContent: "center",
2485
+ zIndex: 9999,
2486
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'
2487
+ },
2488
+ card: {
2489
+ backgroundColor: "#fff",
2490
+ borderRadius: "12px",
2491
+ padding: "24px",
2492
+ maxWidth: "420px",
2493
+ width: "90%",
2494
+ boxShadow: "0 25px 50px -12px rgba(0,0,0,0.25)"
2495
+ },
2496
+ title: {
2497
+ fontSize: "18px",
2498
+ fontWeight: 700,
2499
+ color: "#111827",
2500
+ margin: "0 0 20px 0",
2501
+ textAlign: "center"
2502
+ },
2503
+ providerButton: {
2504
+ display: "flex",
2505
+ alignItems: "center",
2506
+ width: "100%",
2507
+ padding: "12px 16px",
2508
+ border: "1px solid #e5e7eb",
2509
+ borderRadius: "8px",
2510
+ backgroundColor: "#fff",
2511
+ cursor: "pointer",
2512
+ fontSize: "14px",
2513
+ fontWeight: 500,
2514
+ color: "#111827",
2515
+ transition: "background-color 0.15s",
2516
+ fontFamily: "inherit"
2517
+ },
2518
+ cancelButton: {
2519
+ display: "block",
2520
+ width: "100%",
2521
+ marginTop: "16px",
2522
+ padding: "10px",
2523
+ border: "none",
2524
+ borderRadius: "8px",
2525
+ backgroundColor: "#f3f4f6",
2526
+ color: "#6b7280",
2527
+ fontSize: "14px",
2528
+ fontWeight: 500,
2529
+ cursor: "pointer",
2530
+ fontFamily: "inherit"
2531
+ }
2532
+ };
2512
2533
  function ProviderModal({
2513
2534
  providers,
2514
2535
  isPending,
@@ -2546,7 +2567,7 @@ function TransferModal2({
2546
2567
  const bankDetails = data.bankDetails;
2547
2568
  const plan = data.plan;
2548
2569
  const intent = data.intent;
2549
- const displayAmount = plan ? formatAmount2(plan.amount, plan.currency) : intent ? formatAmount2(intent.amount * 100, intent.currency) : "";
2570
+ const displayAmount = plan ? formatAmount(plan.amount, plan.currency) : intent ? formatAmount(intent.amount, intent.currency) : "";
2550
2571
  return /* @__PURE__ */ jsx("div", { style: modalStyles.overlay, onClick: onClose, children: /* @__PURE__ */ jsxs("div", { style: modalStyles.card, onClick: (e) => e.stopPropagation(), children: [
2551
2572
  /* @__PURE__ */ jsx("h2", { style: modalStyles.title, children: labels?.bankTransfer ?? "Bank Transfer" }),
2552
2573
  displayAmount && /* @__PURE__ */ jsxs(
@@ -2626,62 +2647,114 @@ function TransferModal2({
2626
2647
  /* @__PURE__ */ jsx("button", { type: "button", style: modalStyles.cancelButton, onClick: onClose, children: "Close" })
2627
2648
  ] }) });
2628
2649
  }
2629
- var modalStyles = {
2630
- overlay: {
2631
- position: "fixed",
2632
- inset: 0,
2633
- backgroundColor: "rgba(0,0,0,0.5)",
2634
- display: "flex",
2635
- alignItems: "center",
2636
- justifyContent: "center",
2637
- zIndex: 9999,
2638
- fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'
2639
- },
2640
- card: {
2641
- backgroundColor: "#fff",
2642
- borderRadius: "12px",
2643
- padding: "24px",
2644
- maxWidth: "420px",
2645
- width: "90%",
2646
- boxShadow: "0 25px 50px -12px rgba(0,0,0,0.25)"
2647
- },
2648
- title: {
2649
- fontSize: "18px",
2650
- fontWeight: 700,
2651
- color: "#111827",
2652
- margin: "0 0 20px 0",
2653
- textAlign: "center"
2654
- },
2655
- providerButton: {
2656
- display: "flex",
2657
- alignItems: "center",
2658
- width: "100%",
2659
- padding: "12px 16px",
2660
- border: "1px solid #e5e7eb",
2661
- borderRadius: "8px",
2662
- backgroundColor: "#fff",
2663
- cursor: "pointer",
2664
- fontSize: "14px",
2665
- fontWeight: 500,
2666
- color: "#111827",
2667
- transition: "background-color 0.15s",
2668
- fontFamily: "inherit"
2669
- },
2670
- cancelButton: {
2671
- display: "block",
2672
- width: "100%",
2673
- marginTop: "16px",
2674
- padding: "10px",
2675
- border: "none",
2676
- borderRadius: "8px",
2677
- backgroundColor: "#f3f4f6",
2678
- color: "#6b7280",
2679
- fontSize: "14px",
2680
- fontWeight: 500,
2681
- cursor: "pointer",
2682
- fontFamily: "inherit"
2683
- }
2684
- };
2650
+ function PayButton({
2651
+ planId,
2652
+ intentId,
2653
+ successUrl,
2654
+ cancelUrl,
2655
+ className,
2656
+ style,
2657
+ children,
2658
+ disabled,
2659
+ onSuccess,
2660
+ onError,
2661
+ onProviderSelect
2662
+ }) {
2663
+ const messages = useMessages();
2664
+ const billing = messages?.billing;
2665
+ const [showProviderModal, setShowProviderModal] = useState(false);
2666
+ const [showTransferModal, setShowTransferModal] = useState(false);
2667
+ const [transferData, setTransferData] = useState(null);
2668
+ const [payphoneData, setPayphoneData] = useState(null);
2669
+ const { data: providers, isLoading: providersLoading } = usePaymentProviders();
2670
+ const { checkout, isPending } = useCheckout({
2671
+ redirectOnSuccess: true,
2672
+ onSuccess: (data) => {
2673
+ if (data.provider === "MANUAL_TRANSFER") {
2674
+ setTransferData(data);
2675
+ setShowTransferModal(true);
2676
+ setShowProviderModal(false);
2677
+ } else if (data.provider === "PAYPHONE" && data.widgetConfig) {
2678
+ setPayphoneData(data);
2679
+ setShowProviderModal(false);
2680
+ }
2681
+ onSuccess?.(data);
2682
+ },
2683
+ onError
2684
+ });
2685
+ const handleClick = () => {
2686
+ if (!providers || providers.length === 0) return;
2687
+ if (providers.length === 1) {
2688
+ doCheckout(providers[0].provider);
2689
+ } else {
2690
+ setShowProviderModal(true);
2691
+ }
2692
+ };
2693
+ const doCheckout = (provider) => {
2694
+ onProviderSelect?.(provider);
2695
+ checkout({
2696
+ planId,
2697
+ intentId,
2698
+ provider,
2699
+ successUrl,
2700
+ cancelUrl
2701
+ });
2702
+ };
2703
+ const isDisabled = disabled || isPending || providersLoading || !planId && !intentId;
2704
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2705
+ /* @__PURE__ */ jsx(
2706
+ "button",
2707
+ {
2708
+ type: "button",
2709
+ className,
2710
+ style: {
2711
+ padding: "10px 24px",
2712
+ fontSize: "14px",
2713
+ fontWeight: 600,
2714
+ color: "#fff",
2715
+ backgroundColor: isDisabled ? "#9ca3af" : "#111827",
2716
+ border: "none",
2717
+ borderRadius: "8px",
2718
+ cursor: isDisabled ? "not-allowed" : "pointer",
2719
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
2720
+ ...style
2721
+ },
2722
+ onClick: handleClick,
2723
+ disabled: isDisabled,
2724
+ children: isPending ? billing?.processing ?? "Processing..." : children ?? (billing?.pay ?? "Pay")
2725
+ }
2726
+ ),
2727
+ showProviderModal && providers && providers.length > 1 && /* @__PURE__ */ jsx(
2728
+ ProviderModal,
2729
+ {
2730
+ providers,
2731
+ isPending,
2732
+ onSelect: doCheckout,
2733
+ onClose: () => setShowProviderModal(false),
2734
+ labels: billing
2735
+ }
2736
+ ),
2737
+ showTransferModal && transferData && /* @__PURE__ */ jsx(
2738
+ TransferModal2,
2739
+ {
2740
+ data: transferData,
2741
+ onClose: () => {
2742
+ setShowTransferModal(false);
2743
+ setTransferData(null);
2744
+ },
2745
+ labels: billing
2746
+ }
2747
+ ),
2748
+ payphoneData?.widgetConfig && /* @__PURE__ */ jsx(
2749
+ PayphoneModal,
2750
+ {
2751
+ config: payphoneData.widgetConfig,
2752
+ successUrl,
2753
+ onClose: () => setPayphoneData(null)
2754
+ }
2755
+ )
2756
+ ] });
2757
+ }
2685
2758
  function usePayphoneConfirm(options) {
2686
2759
  const client = useAccessClient();
2687
2760
  return useMutation({
@@ -2747,7 +2820,7 @@ var statusConfig = {
2747
2820
  UNPAID: { bg: "#fee2e2", color: "#991b1b", label: "Unpaid" },
2748
2821
  INCOMPLETE: { bg: "#f3f4f6", color: "#6b7280", label: "Incomplete" }
2749
2822
  };
2750
- var styles4 = {
2823
+ var styles6 = {
2751
2824
  badge: {
2752
2825
  display: "inline-flex",
2753
2826
  alignItems: "center",
@@ -2776,7 +2849,7 @@ var styles4 = {
2776
2849
  function SubscriptionBadge({ className, style }) {
2777
2850
  const { data: subscription, isLoading } = useSubscription();
2778
2851
  if (isLoading) {
2779
- return /* @__PURE__ */ jsx("span", { className, style: { ...styles4.skeleton, ...style } });
2852
+ return /* @__PURE__ */ jsx("span", { className, style: { ...styles6.skeleton, ...style } });
2780
2853
  }
2781
2854
  if (!subscription) {
2782
2855
  return /* @__PURE__ */ jsx(
@@ -2784,7 +2857,7 @@ function SubscriptionBadge({ className, style }) {
2784
2857
  {
2785
2858
  className,
2786
2859
  style: {
2787
- ...styles4.badge,
2860
+ ...styles6.badge,
2788
2861
  backgroundColor: "#f3f4f6",
2789
2862
  color: "#6b7280",
2790
2863
  ...style
@@ -2799,13 +2872,13 @@ function SubscriptionBadge({ className, style }) {
2799
2872
  {
2800
2873
  className,
2801
2874
  style: {
2802
- ...styles4.badge,
2875
+ ...styles6.badge,
2803
2876
  backgroundColor: config.bg,
2804
2877
  color: config.color,
2805
2878
  ...style
2806
2879
  },
2807
2880
  children: [
2808
- /* @__PURE__ */ jsx("span", { style: styles4.dot(config.color), "aria-hidden": "true" }),
2881
+ /* @__PURE__ */ jsx("span", { style: styles6.dot(config.color), "aria-hidden": "true" }),
2809
2882
  subscription.plan.name,
2810
2883
  " \xB7 ",
2811
2884
  config.label
@@ -2839,19 +2912,7 @@ function formatDate2(dateStr) {
2839
2912
  return dateStr;
2840
2913
  }
2841
2914
  }
2842
- function formatAmount3(amount, currency) {
2843
- try {
2844
- return new Intl.NumberFormat(void 0, {
2845
- style: "currency",
2846
- currency,
2847
- minimumFractionDigits: 0,
2848
- maximumFractionDigits: 2
2849
- }).format(amount / 100);
2850
- } catch {
2851
- return `${currency} ${(amount / 100).toFixed(2)}`;
2852
- }
2853
- }
2854
- var styles5 = {
2915
+ var styles7 = {
2855
2916
  container: {
2856
2917
  border: "1px solid #e5e7eb",
2857
2918
  borderRadius: "12px",
@@ -2920,41 +2981,41 @@ var styles5 = {
2920
2981
  function InvoiceList({ className, style }) {
2921
2982
  const { data: invoices, isLoading } = useInvoices();
2922
2983
  if (isLoading) {
2923
- return /* @__PURE__ */ jsxs("div", { className, style: { ...styles5.container, ...style }, children: [
2924
- /* @__PURE__ */ jsx("div", { style: styles5.header, children: /* @__PURE__ */ jsx("div", { style: { ...styles5.skeleton, width: "100px", height: "18px" } }) }),
2984
+ return /* @__PURE__ */ jsxs("div", { className, style: { ...styles7.container, ...style }, children: [
2985
+ /* @__PURE__ */ jsx("div", { style: styles7.header, children: /* @__PURE__ */ jsx("div", { style: { ...styles7.skeleton, width: "100px", height: "18px" } }) }),
2925
2986
  /* @__PURE__ */ jsx("div", { style: { padding: "24px" }, children: [1, 2, 3].map((i) => /* @__PURE__ */ jsx(
2926
2987
  "div",
2927
2988
  {
2928
- style: { ...styles5.skeleton, width: "100%", height: "16px", marginBottom: "16px" }
2989
+ style: { ...styles7.skeleton, width: "100%", height: "16px", marginBottom: "16px" }
2929
2990
  },
2930
2991
  i
2931
2992
  )) })
2932
2993
  ] });
2933
2994
  }
2934
- return /* @__PURE__ */ jsxs("div", { className, style: { ...styles5.container, ...style }, children: [
2935
- /* @__PURE__ */ jsx("div", { style: styles5.header, children: /* @__PURE__ */ jsx("h3", { style: styles5.title, children: "Invoices" }) }),
2936
- /* @__PURE__ */ jsxs("table", { style: styles5.table, children: [
2995
+ return /* @__PURE__ */ jsxs("div", { className, style: { ...styles7.container, ...style }, children: [
2996
+ /* @__PURE__ */ jsx("div", { style: styles7.header, children: /* @__PURE__ */ jsx("h3", { style: styles7.title, children: "Invoices" }) }),
2997
+ /* @__PURE__ */ jsxs("table", { style: styles7.table, children: [
2937
2998
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
2938
- /* @__PURE__ */ jsx("th", { style: styles5.th, children: "Date" }),
2939
- /* @__PURE__ */ jsx("th", { style: styles5.th, children: "Amount" }),
2940
- /* @__PURE__ */ jsx("th", { style: styles5.th, children: "Status" }),
2941
- /* @__PURE__ */ jsx("th", { style: styles5.th, children: "Invoice" })
2999
+ /* @__PURE__ */ jsx("th", { style: styles7.th, children: "Date" }),
3000
+ /* @__PURE__ */ jsx("th", { style: styles7.th, children: "Amount" }),
3001
+ /* @__PURE__ */ jsx("th", { style: styles7.th, children: "Status" }),
3002
+ /* @__PURE__ */ jsx("th", { style: styles7.th, children: "Invoice" })
2942
3003
  ] }) }),
2943
3004
  /* @__PURE__ */ jsxs("tbody", { children: [
2944
- (!invoices || invoices.length === 0) && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: 4, style: styles5.emptyRow, children: "No invoices yet." }) }),
3005
+ (!invoices || invoices.length === 0) && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: 4, style: styles7.emptyRow, children: "No invoices yet." }) }),
2945
3006
  invoices?.map((invoice) => {
2946
3007
  const sc = statusColors2[invoice.status];
2947
3008
  return /* @__PURE__ */ jsxs("tr", { children: [
2948
- /* @__PURE__ */ jsx("td", { style: styles5.td, children: formatDate2(invoice.createdAt) }),
2949
- /* @__PURE__ */ jsx("td", { style: styles5.td, children: formatAmount3(invoice.amount, invoice.currency) }),
2950
- /* @__PURE__ */ jsx("td", { style: styles5.td, children: /* @__PURE__ */ jsx("span", { style: styles5.badge(sc.bg, sc.color), children: invoice.status }) }),
2951
- /* @__PURE__ */ jsx("td", { style: styles5.td, children: invoice.invoiceUrl ? /* @__PURE__ */ jsx(
3009
+ /* @__PURE__ */ jsx("td", { style: styles7.td, children: formatDate2(invoice.createdAt) }),
3010
+ /* @__PURE__ */ jsx("td", { style: styles7.td, children: formatAmount(invoice.amount, invoice.currency) }),
3011
+ /* @__PURE__ */ jsx("td", { style: styles7.td, children: /* @__PURE__ */ jsx("span", { style: styles7.badge(sc.bg, sc.color), children: invoice.status }) }),
3012
+ /* @__PURE__ */ jsx("td", { style: styles7.td, children: invoice.invoiceUrl ? /* @__PURE__ */ jsx(
2952
3013
  "a",
2953
3014
  {
2954
3015
  href: invoice.invoiceUrl,
2955
3016
  target: "_blank",
2956
3017
  rel: "noopener noreferrer",
2957
- style: styles5.link,
3018
+ style: styles7.link,
2958
3019
  children: "View"
2959
3020
  }
2960
3021
  ) : /* @__PURE__ */ jsx("span", { style: { color: "#d1d5db" }, children: "\u2014" }) })
@@ -3212,6 +3273,42 @@ function useTransferProofs() {
3212
3273
  queryFn: () => client.get(client.paths.transferProofs)
3213
3274
  });
3214
3275
  }
3276
+ function useTenants() {
3277
+ const client = useAccessClient();
3278
+ return useQuery({
3279
+ queryKey: ["azirid-access", "tenants"],
3280
+ queryFn: () => client.get(client.paths.userTenants),
3281
+ enabled: !!client.getAccessToken()
3282
+ });
3283
+ }
3284
+ function useTenantMembers(tenantId) {
3285
+ const client = useAccessClient();
3286
+ return useQuery({
3287
+ queryKey: ["azirid-access", "tenants", tenantId, "members"],
3288
+ queryFn: () => client.get(`${client.paths.userTenants}/${tenantId}/members`),
3289
+ enabled: !!client.getAccessToken() && !!tenantId
3290
+ });
3291
+ }
3292
+ function useSwitchTenant() {
3293
+ const client = useAccessClient();
3294
+ const queryClient = useQueryClient();
3295
+ const switchTenant = async (tenantId) => {
3296
+ await client.refreshSession({ tenantId });
3297
+ await queryClient.invalidateQueries({ queryKey: ["azirid-access"] });
3298
+ };
3299
+ return { switchTenant };
3300
+ }
3301
+ function createMutationHook(config) {
3302
+ return function useGeneratedMutation(options) {
3303
+ const client = useAccessClient();
3304
+ return useMutation({
3305
+ mutationKey: config.mutationKey,
3306
+ mutationFn: (input) => config.mutationFn(client, input),
3307
+ onSuccess: options?.onSuccess,
3308
+ onError: options?.onError
3309
+ });
3310
+ };
3311
+ }
3215
3312
  function zodToFieldErrors(zodError) {
3216
3313
  return zodError.issues.map((issue) => ({
3217
3314
  field: issue.path.join("."),
@@ -3268,8 +3365,8 @@ function usePasswordToggle() {
3268
3365
  }
3269
3366
 
3270
3367
  // src/index.ts
3271
- var SDK_VERSION = "0.6.0";
3368
+ var SDK_VERSION = "0.8.0";
3272
3369
 
3273
- export { AziridProvider, BASE_PATHS, CheckoutButton, InvoiceList, LoginForm, PATHS, PayButton, PayphoneCallback, PricingTable, ReferralCard, ReferralStats, SDK_VERSION, SignupForm, SubscriptionBadge, buildPaths, changePasswordSchema, cn, createAccessClient, createLoginSchema, createSignupSchema, en, es, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordToggle, usePaymentProviders, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useTransferProofs };
3370
+ export { AziridProvider, BASE_PATHS, CheckoutButton, InvoiceList, LoginForm, PATHS, PayButton, PayphoneCallback, PricingTable, ReferralCard, ReferralStats, SDK_VERSION, SignupForm, SubscriptionBadge, buildPaths, changePasswordSchema, cn, createAccessClient, createLoginSchema, createMutationHook, createSignupSchema, en, es, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordToggle, usePaymentProviders, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferProofs };
3274
3371
  //# sourceMappingURL=index.js.map
3275
3372
  //# sourceMappingURL=index.js.map