@streamoid/settings 0.15.0 → 0.15.2

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
@@ -26,6 +26,9 @@ __export(index_exports, {
26
26
  AppSettingsPage: () => AppSettingsPage,
27
27
  AppSettingsRow: () => AppSettingsRow,
28
28
  AppSettingsSection: () => AppSettingsSection,
29
+ BILLING_TABLE_FRAME_STYLE: () => BILLING_TABLE_FRAME_STYLE,
30
+ BILLING_TABLE_MIN_HEIGHT: () => BILLING_TABLE_MIN_HEIGHT,
31
+ BILLING_TABLE_PAGER_STYLE: () => BILLING_TABLE_PAGER_STYLE,
29
32
  BillingContent: () => BillingContent,
30
33
  BuyCreditsModal: () => BuyCreditsModal,
31
34
  ConfirmDeleteModal: () => ConfirmDeleteModal,
@@ -124,6 +127,7 @@ __export(index_exports, {
124
127
  poolErrorMessage: () => poolErrorMessage,
125
128
  poolRenewsAtCycleEnd: () => poolRenewsAtCycleEnd,
126
129
  poolWorkspaceName: () => poolWorkspaceName,
130
+ productsForCountry: () => productsForCountry,
127
131
  readSettingsCaller: () => readSettingsCaller,
128
132
  rememberSettingsCaller: () => rememberSettingsCaller,
129
133
  resolveSettingsTabFromPath: () => resolveSettingsTabFromPath,
@@ -140,6 +144,7 @@ __export(index_exports, {
140
144
  usageLogsExportFileName: () => usageLogsExportFileName,
141
145
  usageLogsPage: () => usageLogsPage,
142
146
  usageLogsReducer: () => usageLogsReducer,
147
+ usageLogsReloadPage: () => usageLogsReloadPage,
143
148
  usageLogsSpentByOthers: () => usageLogsSpentByOthers,
144
149
  useBillingEntitlement: () => useBillingEntitlement,
145
150
  useSettingsAdapters: () => useSettingsAdapters,
@@ -10698,6 +10703,34 @@ async function loadCurrentPlan(fetchCurrentPlan) {
10698
10703
  return { subscription, entitlement, paid: hasPaidFeatures({ entitlement, subscription }) };
10699
10704
  }
10700
10705
 
10706
+ // src/billing-layout.ts
10707
+ var BILLING_TABLE_MIN_HEIGHT = 300;
10708
+ var BILLING_TABLE_FRAME_STYLE = {
10709
+ flex: "1 0 auto",
10710
+ minHeight: BILLING_TABLE_MIN_HEIGHT,
10711
+ backgroundColor: "var(--alias-surface-base)",
10712
+ borderRadius: "var(--radius-3xl)",
10713
+ border: "1px solid var(--alias-border-subtle)",
10714
+ overflow: "clip"
10715
+ };
10716
+ var BILLING_TABLE_PAGER_STYLE = {
10717
+ position: "sticky",
10718
+ bottom: 0,
10719
+ zIndex: 2,
10720
+ backgroundColor: "var(--alias-surface-canvas)",
10721
+ paddingTop: "var(--spacing-xl)",
10722
+ paddingBottom: "var(--spacing-md)"
10723
+ };
10724
+ function productsForCountry(products, country) {
10725
+ const currency = country?.trim().toUpperCase() === "IN" ? "inr" : "usd";
10726
+ return products.map((product) => ({
10727
+ ...product,
10728
+ prices: product.prices.filter(
10729
+ (price) => price.currency?.toLowerCase() === currency
10730
+ )
10731
+ })).filter((product) => product.prices.length > 0);
10732
+ }
10733
+
10701
10734
  // src/usage-logs.ts
10702
10735
  var USAGE_LOGS_PAGE_SIZE = 50;
10703
10736
  var USAGE_LOGS_EXPORT_BATCH_SIZE = 100;
@@ -10773,6 +10806,9 @@ function usageLogsReducer(state, action) {
10773
10806
  return INITIAL_USAGE_LOGS_STATE;
10774
10807
  }
10775
10808
  }
10809
+ function usageLogsReloadPage(state) {
10810
+ return Math.max(1, Math.floor(state.requestedPage) || 1);
10811
+ }
10776
10812
  function usageLogsSpentByOthers(logs, workspaceId) {
10777
10813
  return (logs.unpaged ?? logs.rows).some(
10778
10814
  (log) => usedByWorkspaceKey(log, workspaceId) !== null
@@ -11711,63 +11747,51 @@ function InvoiceHistoryTable({
11711
11747
  }
11712
11748
  );
11713
11749
  }
11714
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
11715
- "div",
11716
- {
11717
- className: "flex-1 min-h-0 w-full relative",
11718
- style: {
11719
- backgroundColor: "var(--alias-surface-base)",
11720
- borderRadius: "var(--radius-3xl)",
11721
- border: "1px solid var(--alias-border-subtle)",
11722
- overflowY: "auto"
11723
- },
11724
- children: [
11725
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11726
- "div",
11750
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "w-full relative", style: BILLING_TABLE_FRAME_STYLE, children: [
11751
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11752
+ "div",
11753
+ {
11754
+ style: {
11755
+ position: "sticky",
11756
+ top: 0,
11757
+ zIndex: 1,
11758
+ backgroundColor: "var(--alias-surface-base)"
11759
+ },
11760
+ children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_ui17.ScBillingHistoryHeader, {})
11761
+ }
11762
+ ),
11763
+ invoices.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11764
+ "div",
11765
+ {
11766
+ className: "flex items-center justify-center w-full",
11767
+ style: { padding: "var(--spacing-6xl)" },
11768
+ children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11769
+ "span",
11727
11770
  {
11728
11771
  style: {
11729
- position: "sticky",
11730
- top: 0,
11731
- zIndex: 1,
11732
- backgroundColor: "var(--alias-surface-base)"
11772
+ fontFamily: "var(--font-family-font-family-body)",
11773
+ fontSize: "var(--font-size-font-size-sm)",
11774
+ fontWeight: 400,
11775
+ lineHeight: "var(--line-height-line-height-sm)",
11776
+ color: "var(--alias-text---icons-muted)"
11733
11777
  },
11734
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_ui17.ScBillingHistoryHeader, {})
11735
- }
11736
- ),
11737
- invoices.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11738
- "div",
11739
- {
11740
- className: "flex items-center justify-center w-full",
11741
- style: { padding: "var(--spacing-6xl)" },
11742
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11743
- "span",
11744
- {
11745
- style: {
11746
- fontFamily: "var(--font-family-font-family-body)",
11747
- fontSize: "var(--font-size-font-size-sm)",
11748
- fontWeight: 400,
11749
- lineHeight: "var(--line-height-line-height-sm)",
11750
- color: "var(--alias-text---icons-muted)"
11751
- },
11752
- children: "No invoices found"
11753
- }
11754
- )
11778
+ children: "No invoices found"
11755
11779
  }
11756
- ),
11757
- invoices.map((inv) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11758
- import_ui17.ScBillingHistoryTableList,
11759
- {
11760
- invoiceNumber: inv.transactionId ? `# ${inv.transactionId.slice(0, 16).toUpperCase()}` : "# INV-UNKNOWN",
11761
- amount: inv.amountPaid != null ? `${currencySymbol}${inv.amountPaid.toFixed(2)}` : `${currencySymbol}${(inv.amount / 100).toFixed(2)}`,
11762
- date: formatDate3(inv.createdAt),
11763
- downloadLabel: "Download invoice",
11764
- onClick: (e) => handleRowClick(e, inv)
11765
- },
11766
- inv._id
11767
- ))
11768
- ]
11769
- }
11770
- );
11780
+ )
11781
+ }
11782
+ ),
11783
+ invoices.map((inv) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11784
+ import_ui17.ScBillingHistoryTableList,
11785
+ {
11786
+ invoiceNumber: inv.transactionId ? `# ${inv.transactionId.slice(0, 16).toUpperCase()}` : "# INV-UNKNOWN",
11787
+ amount: inv.amountPaid != null ? `${currencySymbol}${inv.amountPaid.toFixed(2)}` : `${currencySymbol}${(inv.amount / 100).toFixed(2)}`,
11788
+ date: formatDate3(inv.createdAt),
11789
+ downloadLabel: "Download invoice",
11790
+ onClick: (e) => handleRowClick(e, inv)
11791
+ },
11792
+ inv._id
11793
+ ))
11794
+ ] });
11771
11795
  }
11772
11796
  function UsageLogsTable({
11773
11797
  logs,
@@ -11849,180 +11873,168 @@ function UsageLogsTable({
11849
11873
  }
11850
11874
  );
11851
11875
  }
11852
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
11853
- "div",
11854
- {
11855
- className: "flex-1 min-h-0 w-full relative",
11856
- style: {
11857
- backgroundColor: "var(--alias-surface-base)",
11858
- borderRadius: "var(--radius-3xl)",
11859
- border: "1px solid var(--alias-border-subtle)",
11860
- overflowY: "auto"
11861
- },
11862
- children: [
11863
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
11864
- "div",
11876
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "w-full relative", style: BILLING_TABLE_FRAME_STYLE, children: [
11877
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
11878
+ "div",
11879
+ {
11880
+ style: {
11881
+ position: "sticky",
11882
+ top: 0,
11883
+ zIndex: 1,
11884
+ background: "var(--alias-fill-neutral-neutral, #1a1a1a)",
11885
+ padding: "var(--spacing-xl, 0.75rem) var(--spacing-3xl, 1rem)",
11886
+ display: "flex",
11887
+ flexDirection: "row",
11888
+ gap: "var(--spacing-6xl, 1.5rem)",
11889
+ alignItems: "center"
11890
+ },
11891
+ children: [
11892
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11893
+ import_ui17.ScHeader,
11894
+ {
11895
+ text: "App",
11896
+ state: "none",
11897
+ style: { flex: 1, alignItems: "flex-start", gap: "0.25rem" }
11898
+ }
11899
+ ),
11900
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11901
+ import_ui17.ScHeader,
11902
+ {
11903
+ text: "Activity",
11904
+ state: "none",
11905
+ style: { flex: 1, alignItems: "flex-start", gap: "0.25rem" }
11906
+ }
11907
+ ),
11908
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11909
+ import_ui17.ScHeader,
11910
+ {
11911
+ text: "Used by",
11912
+ state: "none",
11913
+ style: { flexShrink: 0, width: "7.5rem" }
11914
+ }
11915
+ ),
11916
+ showWorkspace && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11917
+ import_ui17.ScHeader,
11918
+ {
11919
+ text: "Workspace",
11920
+ state: "none",
11921
+ style: { flexShrink: 0, width: "9rem" }
11922
+ }
11923
+ ),
11924
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11925
+ import_ui17.ScHeader,
11926
+ {
11927
+ text: "Date",
11928
+ state: "none",
11929
+ style: { flexShrink: 0, width: "7.5rem" }
11930
+ }
11931
+ ),
11932
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11933
+ import_ui17.ScHeader,
11934
+ {
11935
+ text: "Credits",
11936
+ state: "none",
11937
+ style: {
11938
+ flexShrink: 0,
11939
+ width: "5rem",
11940
+ justifyContent: "flex-end"
11941
+ }
11942
+ }
11943
+ )
11944
+ ]
11945
+ }
11946
+ ),
11947
+ logs.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11948
+ "div",
11949
+ {
11950
+ className: "flex items-center justify-center w-full",
11951
+ style: { padding: "var(--spacing-6xl)" },
11952
+ children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11953
+ "span",
11865
11954
  {
11866
11955
  style: {
11867
- position: "sticky",
11868
- top: 0,
11869
- zIndex: 1,
11870
- background: "var(--alias-fill-neutral-neutral, #1a1a1a)",
11871
- padding: "var(--spacing-xl, 0.75rem) var(--spacing-3xl, 1rem)",
11872
- display: "flex",
11873
- flexDirection: "row",
11874
- gap: "var(--spacing-6xl, 1.5rem)",
11875
- alignItems: "center"
11956
+ fontFamily: "var(--font-family-font-family-body)",
11957
+ fontSize: "var(--font-size-font-size-sm)",
11958
+ fontWeight: 400,
11959
+ lineHeight: "var(--line-height-line-height-sm)",
11960
+ color: "var(--alias-text---icons-muted)"
11876
11961
  },
11877
- children: [
11878
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11879
- import_ui17.ScHeader,
11880
- {
11881
- text: "App",
11882
- state: "none",
11883
- style: { flex: 1, alignItems: "flex-start", gap: "0.25rem" }
11884
- }
11885
- ),
11886
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11887
- import_ui17.ScHeader,
11888
- {
11889
- text: "Activity",
11890
- state: "none",
11891
- style: { flex: 1, alignItems: "flex-start", gap: "0.25rem" }
11892
- }
11893
- ),
11894
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11895
- import_ui17.ScHeader,
11896
- {
11897
- text: "Used by",
11898
- state: "none",
11899
- style: { flexShrink: 0, width: "7.5rem" }
11900
- }
11901
- ),
11902
- showWorkspace && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11903
- import_ui17.ScHeader,
11904
- {
11905
- text: "Workspace",
11906
- state: "none",
11907
- style: { flexShrink: 0, width: "9rem" }
11908
- }
11909
- ),
11910
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11911
- import_ui17.ScHeader,
11912
- {
11913
- text: "Date",
11914
- state: "none",
11915
- style: { flexShrink: 0, width: "7.5rem" }
11916
- }
11917
- ),
11918
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11919
- import_ui17.ScHeader,
11920
- {
11921
- text: "Credits",
11922
- state: "none",
11923
- style: {
11924
- flexShrink: 0,
11925
- width: "5rem",
11926
- justifyContent: "flex-end"
11927
- }
11928
- }
11929
- )
11930
- ]
11962
+ children: "No usage logs found"
11931
11963
  }
11932
- ),
11933
- logs.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11934
- "div",
11935
- {
11936
- className: "flex items-center justify-center w-full",
11937
- style: { padding: "var(--spacing-6xl)" },
11938
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11939
- "span",
11964
+ )
11965
+ }
11966
+ ),
11967
+ logs.map((log) => {
11968
+ const userName = log.triggeredByUserId ? userMap[log.triggeredByUserId] || "Unknown" : "System";
11969
+ const app = log.service?.serviceGroupName || "\u2014";
11970
+ const usedBy = usedByWorkspaceKey(log, currentWorkspaceId);
11971
+ const workspaceLabel2 = usedBy ? `Used by ${usedByNames[usedBy.toLowerCase()] ?? "another workspace"}` : "This workspace";
11972
+ const activity = log.type === "return" ? "Returned Credits" : log.meta?.info || "Credit usage";
11973
+ const isPositive = log.type === "return" || log.type === "add";
11974
+ const signedAmount = `${isPositive ? "+" : "-"}${log.amount}`;
11975
+ const amountColor = isPositive ? "var(--alias-text---icons-success, #1aa055)" : "var(--alias-text---icons-error, #d11a1a)";
11976
+ const rowCellRegular = {
11977
+ color: "var(--alias-text---icons-primary, #f5f5f5)",
11978
+ fontFamily: "var(--font-family-font-family-body)",
11979
+ fontSize: "var(--font-size-font-size-sm, 0.875rem)",
11980
+ fontWeight: 400,
11981
+ lineHeight: "var(--line-height-line-height-sm, 1.25rem)",
11982
+ textOverflow: "ellipsis",
11983
+ overflow: "hidden",
11984
+ whiteSpace: "nowrap"
11985
+ };
11986
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
11987
+ "div",
11988
+ {
11989
+ style: {
11990
+ borderBottom: "0.0625rem solid var(--alias-border-subtle, #242424)",
11991
+ padding: "8px 16px",
11992
+ display: "flex",
11993
+ flexDirection: "row",
11994
+ gap: "var(--spacing-6xl, 1.5rem)",
11995
+ alignItems: "center"
11996
+ },
11997
+ children: [
11998
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { style: { ...rowCellRegular, flex: 1 }, children: app }),
11999
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { style: { ...rowCellRegular, flex: 1 }, children: activity }),
12000
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { style: { ...rowCellRegular, width: "7.5rem" }, children: userName }),
12001
+ showWorkspace && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
12002
+ "div",
11940
12003
  {
11941
12004
  style: {
12005
+ ...rowCellRegular,
12006
+ width: "9rem",
12007
+ color: usedBy ? "var(--alias-text---icons-primary, #f5f5f5)" : "var(--alias-text---icons-muted)"
12008
+ },
12009
+ title: workspaceLabel2,
12010
+ children: workspaceLabel2
12011
+ }
12012
+ ),
12013
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { style: { ...rowCellRegular, width: "7.5rem" }, children: formatDate3(log.createdAt) }),
12014
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
12015
+ "div",
12016
+ {
12017
+ style: {
12018
+ width: "5rem",
12019
+ color: amountColor,
11942
12020
  fontFamily: "var(--font-family-font-family-body)",
11943
- fontSize: "var(--font-size-font-size-sm)",
11944
- fontWeight: 400,
11945
- lineHeight: "var(--line-height-line-height-sm)",
11946
- color: "var(--alias-text---icons-muted)"
12021
+ fontSize: "var(--font-size-font-size-md, 1rem)",
12022
+ fontWeight: 600,
12023
+ lineHeight: "var(--line-height-line-height-md, 1.5rem)",
12024
+ textAlign: "right",
12025
+ textOverflow: "ellipsis",
12026
+ overflow: "hidden",
12027
+ whiteSpace: "nowrap"
11947
12028
  },
11948
- children: "No usage logs found"
12029
+ children: signedAmount
11949
12030
  }
11950
12031
  )
11951
- }
11952
- ),
11953
- logs.map((log) => {
11954
- const userName = log.triggeredByUserId ? userMap[log.triggeredByUserId] || "Unknown" : "System";
11955
- const app = log.service?.serviceGroupName || "\u2014";
11956
- const usedBy = usedByWorkspaceKey(log, currentWorkspaceId);
11957
- const workspaceLabel2 = usedBy ? `Used by ${usedByNames[usedBy.toLowerCase()] ?? "another workspace"}` : "This workspace";
11958
- const activity = log.type === "return" ? "Returned Credits" : log.meta?.info || "Credit usage";
11959
- const isPositive = log.type === "return" || log.type === "add";
11960
- const signedAmount = `${isPositive ? "+" : "-"}${log.amount}`;
11961
- const amountColor = isPositive ? "var(--alias-text---icons-success, #1aa055)" : "var(--alias-text---icons-error, #d11a1a)";
11962
- const rowCellRegular = {
11963
- color: "var(--alias-text---icons-primary, #f5f5f5)",
11964
- fontFamily: "var(--font-family-font-family-body)",
11965
- fontSize: "var(--font-size-font-size-sm, 0.875rem)",
11966
- fontWeight: 400,
11967
- lineHeight: "var(--line-height-line-height-sm, 1.25rem)",
11968
- textOverflow: "ellipsis",
11969
- overflow: "hidden",
11970
- whiteSpace: "nowrap"
11971
- };
11972
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
11973
- "div",
11974
- {
11975
- style: {
11976
- borderBottom: "0.0625rem solid var(--alias-border-subtle, #242424)",
11977
- padding: "8px 16px",
11978
- display: "flex",
11979
- flexDirection: "row",
11980
- gap: "var(--spacing-6xl, 1.5rem)",
11981
- alignItems: "center"
11982
- },
11983
- children: [
11984
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { style: { ...rowCellRegular, flex: 1 }, children: app }),
11985
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { style: { ...rowCellRegular, flex: 1 }, children: activity }),
11986
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { style: { ...rowCellRegular, width: "7.5rem" }, children: userName }),
11987
- showWorkspace && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
11988
- "div",
11989
- {
11990
- style: {
11991
- ...rowCellRegular,
11992
- width: "9rem",
11993
- color: usedBy ? "var(--alias-text---icons-primary, #f5f5f5)" : "var(--alias-text---icons-muted)"
11994
- },
11995
- title: workspaceLabel2,
11996
- children: workspaceLabel2
11997
- }
11998
- ),
11999
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { style: { ...rowCellRegular, width: "7.5rem" }, children: formatDate3(log.createdAt) }),
12000
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
12001
- "div",
12002
- {
12003
- style: {
12004
- width: "5rem",
12005
- color: amountColor,
12006
- fontFamily: "var(--font-family-font-family-body)",
12007
- fontSize: "var(--font-size-font-size-md, 1rem)",
12008
- fontWeight: 600,
12009
- lineHeight: "var(--line-height-line-height-md, 1.5rem)",
12010
- textAlign: "right",
12011
- textOverflow: "ellipsis",
12012
- overflow: "hidden",
12013
- whiteSpace: "nowrap"
12014
- },
12015
- children: signedAmount
12016
- }
12017
- )
12018
- ]
12019
- },
12020
- log._id
12021
- );
12022
- })
12023
- ]
12024
- }
12025
- );
12032
+ ]
12033
+ },
12034
+ log._id
12035
+ );
12036
+ })
12037
+ ] });
12026
12038
  }
12027
12039
  function UsageLogsPager({
12028
12040
  page,
@@ -12038,7 +12050,7 @@ function UsageLogsPager({
12038
12050
  "div",
12039
12051
  {
12040
12052
  className: "flex items-center justify-between shrink-0 w-full",
12041
- style: { gap: "var(--spacing-md)" },
12053
+ style: { ...BILLING_TABLE_PAGER_STYLE, gap: "var(--spacing-md)" },
12042
12054
  children: [
12043
12055
  /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
12044
12056
  "span",
@@ -12179,7 +12191,12 @@ function BillingContent({
12179
12191
  const [availableCredits, setAvailableCredits] = (0, import_react23.useState)(null);
12180
12192
  const [sharedPool, setSharedPool] = (0, import_react23.useState)(null);
12181
12193
  const [usedByNames, setUsedByNames] = (0, import_react23.useState)({});
12182
- const [products, setProducts] = (0, import_react23.useState)([]);
12194
+ const [allProducts, setProducts] = (0, import_react23.useState)([]);
12195
+ const workspaceCountry = workspace.current?.country;
12196
+ const products = (0, import_react23.useMemo)(
12197
+ () => productsForCountry(allProducts, workspaceCountry),
12198
+ [allProducts, workspaceCountry]
12199
+ );
12183
12200
  const [invoices, setInvoices] = (0, import_react23.useState)([]);
12184
12201
  const [totalCredits, setTotalCredits] = (0, import_react23.useState)(null);
12185
12202
  const [usageLogsState, dispatchUsageLogs] = (0, import_react23.useReducer)(
@@ -12192,6 +12209,8 @@ function BillingContent({
12192
12209
  error: usageLogsError
12193
12210
  } = usageLogsState;
12194
12211
  const usageLogsRequestRef = (0, import_react23.useRef)(0);
12212
+ const usageLogsStateRef = (0, import_react23.useRef)(usageLogsState);
12213
+ usageLogsStateRef.current = usageLogsState;
12195
12214
  const workspaceIdRef = (0, import_react23.useRef)(workspaceId);
12196
12215
  workspaceIdRef.current = workspaceId;
12197
12216
  const loadUsedByNamesRef = (0, import_react23.useRef)(null);
@@ -12250,17 +12269,7 @@ function BillingContent({
12250
12269
  if (creditsRes?.availableCredits != null)
12251
12270
  setAvailableCredits(creditsRes.availableCredits);
12252
12271
  setSharedPool(creditsRes?.sharedPool ?? null);
12253
- if (productsRes?.data) {
12254
- const normalizedWorkspaceCountry = workspace.current?.country?.trim().toUpperCase();
12255
- const targetCurrency = normalizedWorkspaceCountry === "IN" ? "inr" : "usd";
12256
- const filteredProducts = productsRes.data.map((product) => ({
12257
- ...product,
12258
- prices: product.prices.filter(
12259
- (price) => price.currency?.toLowerCase() === targetCurrency
12260
- )
12261
- })).filter((product) => product.prices.length > 0);
12262
- setProducts(filteredProducts);
12263
- }
12272
+ if (productsRes?.data) setProducts(productsRes.data);
12264
12273
  if (customRes?.data?.credits != null) {
12265
12274
  setCustomPlanCredits(customRes.data.credits);
12266
12275
  }
@@ -12269,7 +12278,7 @@ function BillingContent({
12269
12278
  setLoadingBilling(false);
12270
12279
  setBillingOverviewLoaded(true);
12271
12280
  }
12272
- }, [api, workspace.current?.country]);
12281
+ }, [api]);
12273
12282
  const fetchUserMap = (0, import_react23.useCallback)(async () => {
12274
12283
  try {
12275
12284
  const members = await api.fetchMembers();
@@ -12342,7 +12351,7 @@ function BillingContent({
12342
12351
  const fetchTableData = (0, import_react23.useCallback)(
12343
12352
  async (tab) => {
12344
12353
  if (tab === "usage") {
12345
- await loadUsageLogsPage(1);
12354
+ await loadUsageLogsPage(usageLogsReloadPage(usageLogsStateRef.current));
12346
12355
  return;
12347
12356
  }
12348
12357
  setLoadingTable(true);
@@ -12472,6 +12481,7 @@ function BillingContent({
12472
12481
  setCustomPlanCredits(null);
12473
12482
  usageLogsRequestRef.current++;
12474
12483
  dispatchUsageLogs({ type: "reset" });
12484
+ usageLogsStateRef.current = INITIAL_USAGE_LOGS_STATE;
12475
12485
  loadUsedByNamesRef.current?.reset();
12476
12486
  setUsedByNames({});
12477
12487
  }, [workspaceId]);
@@ -13106,30 +13116,34 @@ function BillingContent({
13106
13116
  loading: loadingTable,
13107
13117
  workspaceCountry: workspace.current?.country
13108
13118
  }
13109
- ) : /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
13110
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
13111
- UsageLogsTable,
13112
- {
13113
- logs: usageLogs.rows,
13114
- userMap,
13115
- loading: loadingUsageLogs,
13116
- error: usageLogsError,
13117
- onRetry: () => void loadUsageLogsPage(usageLogsState.requestedPage),
13118
- currentWorkspaceId: workspaceId,
13119
- usedByNames
13120
- }
13121
- ),
13122
- !usageLogsError && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
13123
- UsageLogsPager,
13124
- {
13125
- page: usageLogs.page,
13126
- totalPages: usageLogs.totalPages,
13127
- total: usageLogs.total,
13128
- loading: loadingUsageLogs,
13129
- onPageChange: goToUsageLogsPage
13130
- }
13131
- )
13132
- ] }),
13119
+ ) : (
13120
+ // Table and pager only, so the sticky pager stops at the table's top
13121
+ // and never floats over the cards above it.
13122
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col w-full", style: { flex: "1 0 auto" }, children: [
13123
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
13124
+ UsageLogsTable,
13125
+ {
13126
+ logs: usageLogs.rows,
13127
+ userMap,
13128
+ loading: loadingUsageLogs,
13129
+ error: usageLogsError,
13130
+ onRetry: () => void loadUsageLogsPage(usageLogsState.requestedPage),
13131
+ currentWorkspaceId: workspaceId,
13132
+ usedByNames
13133
+ }
13134
+ ),
13135
+ !usageLogsError && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
13136
+ UsageLogsPager,
13137
+ {
13138
+ page: usageLogs.page,
13139
+ totalPages: usageLogs.totalPages,
13140
+ total: usageLogs.total,
13141
+ loading: loadingUsageLogs,
13142
+ onPageChange: goToUsageLogsPage
13143
+ }
13144
+ )
13145
+ ] })
13146
+ ),
13133
13147
  showExportModal && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
13134
13148
  ExportDateModal,
13135
13149
  {
@@ -13160,7 +13174,7 @@ function BillingContent({
13160
13174
  "div",
13161
13175
  {
13162
13176
  className: "flex flex-col flex-1 min-w-0 min-h-0 w-full",
13163
- style: { gap: 12 },
13177
+ style: { gap: 12, overflowY: "auto" },
13164
13178
  children: billingInnerContent
13165
13179
  }
13166
13180
  );