@streamoid/settings 0.3.0 → 0.3.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.d.mts CHANGED
@@ -658,10 +658,12 @@ interface ConfirmDeleteModalProps {
658
658
  declare function ConfirmDeleteModal({ open, workspaceName, onClose, onConfirm, }: ConfirmDeleteModalProps): react_jsx_runtime.JSX.Element | null;
659
659
 
660
660
  interface BuyCreditsModalProps {
661
+ currencySymbol?: string;
662
+ country?: string;
661
663
  onClose: () => void;
662
664
  onBuy: (credits: number, price: number) => void;
663
665
  }
664
- declare function BuyCreditsModal({ onClose, onBuy }: BuyCreditsModalProps): react_jsx_runtime.JSX.Element;
666
+ declare function BuyCreditsModal({ currencySymbol, country, onClose, onBuy, }: BuyCreditsModalProps): react_jsx_runtime.JSX.Element;
665
667
 
666
668
  interface UserPermissions {
667
669
  artifax: boolean;
package/dist/index.d.ts CHANGED
@@ -658,10 +658,12 @@ interface ConfirmDeleteModalProps {
658
658
  declare function ConfirmDeleteModal({ open, workspaceName, onClose, onConfirm, }: ConfirmDeleteModalProps): react_jsx_runtime.JSX.Element | null;
659
659
 
660
660
  interface BuyCreditsModalProps {
661
+ currencySymbol?: string;
662
+ country?: string;
661
663
  onClose: () => void;
662
664
  onBuy: (credits: number, price: number) => void;
663
665
  }
664
- declare function BuyCreditsModal({ onClose, onBuy }: BuyCreditsModalProps): react_jsx_runtime.JSX.Element;
666
+ declare function BuyCreditsModal({ currencySymbol, country, onClose, onBuy, }: BuyCreditsModalProps): react_jsx_runtime.JSX.Element;
665
667
 
666
668
  interface UserPermissions {
667
669
  artifax: boolean;
package/dist/index.js CHANGED
@@ -3801,37 +3801,63 @@ var import_react7 = require("react");
3801
3801
  var import_icons4 = require("@streamoid/icons");
3802
3802
  var import_jsx_runtime10 = require("react/jsx-runtime");
3803
3803
  var STEP = 500;
3804
- var PRICE_PER_CREDIT = 0.08;
3805
- var MIN_USD = 40;
3806
- var MAX_USD = 1e4;
3807
- var MIN_CREDITS = Math.round(MIN_USD / PRICE_PER_CREDIT);
3808
- var MAX_CREDITS = Math.round(MAX_USD / PRICE_PER_CREDIT);
3809
- function BuyCreditsModal({ onClose, onBuy }) {
3810
- const [credits, setCredits] = (0, import_react7.useState)(MIN_CREDITS);
3811
- const [creditsInput, setCreditsInput] = (0, import_react7.useState)(String(MIN_CREDITS));
3812
- const [priceInput, setPriceInput] = (0, import_react7.useState)(String(MIN_CREDITS * PRICE_PER_CREDIT));
3804
+ var USD_TOPUP_CONFIG = {
3805
+ currencyCode: "usd",
3806
+ pricePerCredit: 0.08,
3807
+ minAmount: 40,
3808
+ maxAmount: 1e4
3809
+ };
3810
+ var INR_TOPUP_CONFIG = {
3811
+ currencyCode: "inr",
3812
+ pricePerCredit: 5,
3813
+ minAmount: 2500,
3814
+ maxAmount: 1e5
3815
+ };
3816
+ function BuyCreditsModal({
3817
+ currencySymbol = "$",
3818
+ country,
3819
+ onClose,
3820
+ onBuy
3821
+ }) {
3822
+ const normalizedCountry = country?.trim().toUpperCase();
3823
+ const topupConfig = normalizedCountry === "IN" ? INR_TOPUP_CONFIG : USD_TOPUP_CONFIG;
3824
+ const minCredits = Math.round(
3825
+ topupConfig.minAmount / topupConfig.pricePerCredit
3826
+ );
3827
+ const maxCredits = Math.round(
3828
+ topupConfig.maxAmount / topupConfig.pricePerCredit
3829
+ );
3830
+ const [credits, setCredits] = (0, import_react7.useState)(minCredits);
3831
+ const [creditsInput, setCreditsInput] = (0, import_react7.useState)(String(minCredits));
3832
+ const [priceInput, setPriceInput] = (0, import_react7.useState)(
3833
+ String(minCredits * topupConfig.pricePerCredit)
3834
+ );
3813
3835
  const [activeField, setActiveField] = (0, import_react7.useState)("credits");
3814
3836
  const parsedCredits = creditsInput.length ? Number(creditsInput) : credits;
3815
3837
  const previewCredits = Number.isFinite(parsedCredits) ? parsedCredits : credits;
3816
3838
  const pricedCredits = previewCredits > 0 ? previewCredits : 0;
3817
- const price = Number((pricedCredits * PRICE_PER_CREDIT).toFixed(2));
3818
- const isBelowMin = price < MIN_USD;
3819
- const isAboveMax = price > MAX_USD;
3839
+ const price = Number(
3840
+ (pricedCredits * topupConfig.pricePerCredit).toFixed(2)
3841
+ );
3842
+ const isBelowMin = price < topupConfig.minAmount;
3843
+ const isAboveMax = price > topupConfig.maxAmount;
3820
3844
  const isError = isBelowMin || isAboveMax;
3821
3845
  const isInvalid = isError;
3822
3846
  const syncFromCredits = (value) => {
3823
3847
  setCredits(value);
3824
3848
  setCreditsInput(String(value));
3825
- setPriceInput(String(Number((value * PRICE_PER_CREDIT).toFixed(2))));
3849
+ setPriceInput(
3850
+ String(Number((value * topupConfig.pricePerCredit).toFixed(2)))
3851
+ );
3826
3852
  };
3827
- const syncFromPrice = (usd) => {
3828
- const derived = Math.round(usd / PRICE_PER_CREDIT);
3853
+ const syncFromPrice = (amount) => {
3854
+ const derived = Math.round(amount / topupConfig.pricePerCredit);
3829
3855
  setCredits(derived);
3830
3856
  setCreditsInput(String(derived));
3831
- setPriceInput(String(usd));
3857
+ setPriceInput(String(amount));
3832
3858
  };
3833
- const handleDecrement = () => syncFromCredits(Math.max(MIN_CREDITS, credits - STEP));
3834
- const handleIncrement = () => syncFromCredits(Math.min(MAX_CREDITS, credits + STEP));
3859
+ const handleDecrement = () => syncFromCredits(Math.max(minCredits, credits - STEP));
3860
+ const handleIncrement = () => syncFromCredits(Math.min(maxCredits, credits + STEP));
3835
3861
  const handleCreditsChange = (value) => {
3836
3862
  const raw = value.replace(/[^\d]/g, "");
3837
3863
  setCreditsInput(raw);
@@ -3840,7 +3866,9 @@ function BuyCreditsModal({ onClose, onBuy }) {
3840
3866
  const next = Number(raw);
3841
3867
  if (!Number.isNaN(next)) {
3842
3868
  setCredits(next);
3843
- setPriceInput(String(Number((next * PRICE_PER_CREDIT).toFixed(2))));
3869
+ setPriceInput(
3870
+ String(Number((next * topupConfig.pricePerCredit).toFixed(2)))
3871
+ );
3844
3872
  }
3845
3873
  };
3846
3874
  const handleCreditsBlur = () => {
@@ -3858,7 +3886,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
3858
3886
  if (!raw.length) return;
3859
3887
  const next = Number(raw);
3860
3888
  if (!Number.isNaN(next) && next >= 0) {
3861
- const derived = Math.round(next / PRICE_PER_CREDIT);
3889
+ const derived = Math.round(next / topupConfig.pricePerCredit);
3862
3890
  setCredits(derived);
3863
3891
  setCreditsInput(String(derived));
3864
3892
  }
@@ -3962,7 +3990,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
3962
3990
  style: {
3963
3991
  width: 24,
3964
3992
  height: 24,
3965
- opacity: credits <= MIN_CREDITS ? 0.3 : 1,
3993
+ opacity: credits <= minCredits ? 0.3 : 1,
3966
3994
  transition: "opacity 0.15s ease"
3967
3995
  },
3968
3996
  onClick: handleDecrement,
@@ -4020,7 +4048,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
4020
4048
  style: {
4021
4049
  width: 24,
4022
4050
  height: 24,
4023
- opacity: credits >= MAX_CREDITS ? 0.3 : 1,
4051
+ opacity: credits >= maxCredits ? 0.3 : 1,
4024
4052
  transition: "opacity 0.15s ease"
4025
4053
  },
4026
4054
  onClick: handleIncrement,
@@ -4051,7 +4079,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
4051
4079
  lineHeight: "var(--line-height-line-height-lg)",
4052
4080
  color: "var(--alias-text---icons-primary)"
4053
4081
  },
4054
- children: "$"
4082
+ children: currencySymbol
4055
4083
  }
4056
4084
  ),
4057
4085
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -4071,7 +4099,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
4071
4099
  onKeyDown: (e) => {
4072
4100
  if (e.key === "Enter") e.currentTarget.blur();
4073
4101
  },
4074
- "aria-label": "Price in USD",
4102
+ "aria-label": "Price",
4075
4103
  style: {
4076
4104
  fontFamily: "var(--font-family-font-family-body)",
4077
4105
  fontSize: "var(--font-size-font-size-lg)",
@@ -4107,7 +4135,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
4107
4135
  lineHeight: "var(--line-height-line-height-sm)",
4108
4136
  color: "var(--alias-text---icons-error)"
4109
4137
  },
4110
- children: isBelowMin ? `Min. ${MIN_CREDITS.toLocaleString()} credits` : `Max. ${MAX_CREDITS.toLocaleString()} credits`
4138
+ children: isBelowMin ? `Min. ${minCredits.toLocaleString()} credits` : `Max. ${maxCredits.toLocaleString()} credits`
4111
4139
  }
4112
4140
  ) })
4113
4141
  }
@@ -4201,6 +4229,9 @@ function formatCurrency(cents, currency) {
4201
4229
  }
4202
4230
  return `$${(cents / 100).toFixed(2)}`;
4203
4231
  }
4232
+ function getCurrencySymbolByCountry(country) {
4233
+ return country?.trim().toUpperCase() === "IN" ? "\u20B9" : "$";
4234
+ }
4204
4235
  function formatCredits(n) {
4205
4236
  return n.toLocaleString("en-US");
4206
4237
  }
@@ -4763,10 +4794,14 @@ function PlansView({
4763
4794
  actionInFlight,
4764
4795
  onPlanAction,
4765
4796
  onCancelDowngrade,
4766
- workspace
4797
+ workspace,
4798
+ isProPlan
4767
4799
  }) {
4768
4800
  console.log("=============", products);
4769
4801
  const { toast } = useSettingsAdapters();
4802
+ const workspaceCurrencySymbol = getCurrencySymbolByCountry(
4803
+ workspace?.country
4804
+ );
4770
4805
  const allPlans = (0, import_react8.useMemo)(() => {
4771
4806
  if (products.length > 0) {
4772
4807
  return products.flatMap(
@@ -4775,7 +4810,7 @@ function PlansView({
4775
4810
  productId: product.id,
4776
4811
  priceId: price.id,
4777
4812
  planName: price.metadata.name,
4778
- price: price.unit_amount === 0 ? price.currency === "inr" ? "\u20B90" : "$0" : `${formatCurrency(price.unit_amount, price.currency ?? "usd")} / month`,
4813
+ price: price.unit_amount === 0 ? price.currency === "inr" ? "\u20B90" : `${workspaceCurrencySymbol}0` : `${formatCurrency(price.unit_amount, price.currency ?? "usd")} / month`,
4779
4814
  credits: `${Number(price.metadata.credits).toLocaleString()} credits`,
4780
4815
  amount: price.unit_amount,
4781
4816
  currency: price.currency?.toLowerCase(),
@@ -4935,7 +4970,7 @@ function PlansView({
4935
4970
  import_ui5.ScPlanCard,
4936
4971
  {
4937
4972
  planName: freePlan?.planName || "Free",
4938
- price: freePlan?.price || "$0",
4973
+ price: freePlan?.price || `${workspaceCurrencySymbol}0`,
4939
4974
  credits: freePlan?.credits || "3,000 credits",
4940
4975
  type: "free",
4941
4976
  features: getPlanFeatures(freePlan?.amount ?? 0),
@@ -5095,13 +5130,13 @@ function PlansView({
5095
5130
  UpdateSubscriptionModal,
5096
5131
  {
5097
5132
  open: showUpgradeConfirmModal,
5098
- currentPlanName: currentPlan?.planName || "Free",
5099
- currentPlanAmount: currentPlan ? currentPlan.amount === 0 ? "$0" : formatCurrency(currentPlan.amount, currentPlan.currency || "") : "$0",
5133
+ currentPlanName: isProPlan ? "Pro" : currentPlan?.planName || "Free",
5134
+ currentPlanAmount: currentPlan ? currentPlan.amount === 0 ? `${workspaceCurrencySymbol}0` : formatCurrency(currentPlan.amount, currentPlan.currency || "") : `${workspaceCurrencySymbol}0`,
5100
5135
  nextPlanName: selectedMiddlePlan?.planName || "Pro",
5101
- nextPlanAmount: selectedMiddlePlan ? selectedMiddlePlan.amount === 0 ? "$0" : formatCurrency(
5136
+ nextPlanAmount: selectedMiddlePlan ? selectedMiddlePlan.amount === 0 ? `${workspaceCurrencySymbol}0` : formatCurrency(
5102
5137
  selectedMiddlePlan.amount,
5103
5138
  selectedMiddlePlan.currency || ""
5104
- ) : "$0",
5139
+ ) : `${workspaceCurrencySymbol}0`,
5105
5140
  nextBillingDateLabel: formatNextBillingDateLabel(currentPlanEndDate),
5106
5141
  loading: isMiddleActionLoading,
5107
5142
  onClose: () => setShowUpgradeConfirmModal(false),
@@ -5164,9 +5199,11 @@ function BillingTabBar({
5164
5199
  }
5165
5200
  function InvoiceHistoryTable({
5166
5201
  invoices,
5167
- loading
5202
+ loading,
5203
+ workspaceCountry
5168
5204
  }) {
5169
5205
  const { api, toast } = useSettingsAdapters();
5206
+ const currencySymbol = getCurrencySymbolByCountry(workspaceCountry);
5170
5207
  const handleDownload = async (item) => {
5171
5208
  const orderId = item.transactionId;
5172
5209
  if (!orderId) {
@@ -5280,7 +5317,7 @@ function InvoiceHistoryTable({
5280
5317
  import_ui5.ScBillingHistoryTableList,
5281
5318
  {
5282
5319
  invoiceNumber: inv.transactionId ? `# ${inv.transactionId.slice(0, 16).toUpperCase()}` : "# INV-UNKNOWN",
5283
- amount: inv.amountPaid != null ? `$${inv.amountPaid.toFixed(2)}` : `$${(inv.amount / 100).toFixed(2)}`,
5320
+ amount: inv.amountPaid != null ? `${currencySymbol}${inv.amountPaid.toFixed(2)}` : `${currencySymbol}${(inv.amount / 100).toFixed(2)}`,
5284
5321
  date: formatDate(inv.createdAt),
5285
5322
  downloadLabel: "Download invoice",
5286
5323
  onClick: (e) => handleRowClick(e, inv)
@@ -5722,13 +5759,13 @@ function BillingContent({
5722
5759
  setShowInitialLoader(false);
5723
5760
  }, [showInitialLoader, initialFetchTriggered, loadingBilling]);
5724
5761
  console.log("subscription", subscription);
5725
- const isProPlan = products.find(
5762
+ const isProPlan = products.some(
5726
5763
  (product) => product.id == subscription?.stripeProductId && product.name == "Paid"
5727
5764
  );
5728
5765
  console.log("isProPlan", isProPlan);
5729
5766
  const planName = isProPlan ? "Pro" : subscription?.plan?.name?.trim() || (subscription?.plan?.amount ? subscription.plan.amount > 0 ? "Pro" : "Free" : "-");
5730
5767
  const isFreePlan = subscription?.plan?.amount == null || subscription.plan.amount === 0;
5731
- const planAmount = subscription?.plan?.amount != null ? `${subscription?.plan?.currency == "inr" ? "\u20B9" : "$"}${(subscription.plan.amount / 100).toFixed(2)} / ${subscription?.plan?.interval}` : "$0";
5768
+ const planAmount = subscription?.plan?.amount != null ? `${subscription?.plan?.currency == "inr" ? "\u20B9" : "$"}${(subscription.plan.amount / 100).toFixed(2)} / ${subscription?.plan?.interval}` : `${getCurrencySymbolByCountry(workspace.current?.country)}0`;
5732
5769
  const usedCredits = availableCredits != null && totalCredits != null ? Math.max(0, totalCredits - availableCredits) : null;
5733
5770
  const progressPct = usedCredits != null && totalCredits != null && totalCredits > 0 ? Math.min(100, Math.round(usedCredits / totalCredits * 100)) : 0;
5734
5771
  const remainingPct = 100 - progressPct;
@@ -5825,12 +5862,13 @@ function BillingContent({
5825
5862
  }
5826
5863
  );
5827
5864
  try {
5865
+ const topupCurrency = workspace.current?.country?.trim().toUpperCase() === "IN" ? "inr" : "usd";
5828
5866
  const res = await api.buyCredits({
5829
5867
  serviceName: DEFAULT_TOPUP_SERVICE,
5830
5868
  credits,
5831
5869
  unitAmount: price,
5832
5870
  itemCount: 1,
5833
- currency: "usd",
5871
+ currency: topupCurrency,
5834
5872
  successUrl: resolveReturnUrl("success"),
5835
5873
  cancelUrl: resolveReturnUrl("cancel"),
5836
5874
  metadata: { source: "self-serve" }
@@ -5927,7 +5965,8 @@ function BillingContent({
5927
5965
  actionInFlight: planActionInFlight,
5928
5966
  onPlanAction: handlePlanAction,
5929
5967
  onCancelDowngrade: handleCancelDowngrade,
5930
- workspace: workspace.current
5968
+ workspace: workspace.current,
5969
+ isProPlan
5931
5970
  }
5932
5971
  );
5933
5972
  if (embedded) return plansView;
@@ -6018,7 +6057,14 @@ function BillingContent({
6018
6057
  }
6019
6058
  )
6020
6059
  ] }),
6021
- activeTab === "invoice" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(InvoiceHistoryTable, { invoices, loading: loadingTable }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
6060
+ activeTab === "invoice" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
6061
+ InvoiceHistoryTable,
6062
+ {
6063
+ invoices,
6064
+ loading: loadingTable,
6065
+ workspaceCountry: workspace.current?.country
6066
+ }
6067
+ ) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
6022
6068
  UsageLogsTable,
6023
6069
  {
6024
6070
  logs: usageLogs,
@@ -6037,6 +6083,8 @@ function BillingContent({
6037
6083
  showBuyCreditsModal && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
6038
6084
  BuyCreditsModal,
6039
6085
  {
6086
+ country: workspace.current?.country,
6087
+ currencySymbol: getCurrencySymbolByCountry(workspace.current?.country),
6040
6088
  onClose: () => setShowBuyCreditsModal(false),
6041
6089
  onBuy: (credits, price) => {
6042
6090
  handleBuyCredits(credits, price);
package/dist/index.mjs CHANGED
@@ -3820,37 +3820,63 @@ import { useState as useState6 } from "react";
3820
3820
  import { SiconClose as SiconClose3, SiconPlus, SiconMinus } from "@streamoid/icons";
3821
3821
  import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
3822
3822
  var STEP = 500;
3823
- var PRICE_PER_CREDIT = 0.08;
3824
- var MIN_USD = 40;
3825
- var MAX_USD = 1e4;
3826
- var MIN_CREDITS = Math.round(MIN_USD / PRICE_PER_CREDIT);
3827
- var MAX_CREDITS = Math.round(MAX_USD / PRICE_PER_CREDIT);
3828
- function BuyCreditsModal({ onClose, onBuy }) {
3829
- const [credits, setCredits] = useState6(MIN_CREDITS);
3830
- const [creditsInput, setCreditsInput] = useState6(String(MIN_CREDITS));
3831
- const [priceInput, setPriceInput] = useState6(String(MIN_CREDITS * PRICE_PER_CREDIT));
3823
+ var USD_TOPUP_CONFIG = {
3824
+ currencyCode: "usd",
3825
+ pricePerCredit: 0.08,
3826
+ minAmount: 40,
3827
+ maxAmount: 1e4
3828
+ };
3829
+ var INR_TOPUP_CONFIG = {
3830
+ currencyCode: "inr",
3831
+ pricePerCredit: 5,
3832
+ minAmount: 2500,
3833
+ maxAmount: 1e5
3834
+ };
3835
+ function BuyCreditsModal({
3836
+ currencySymbol = "$",
3837
+ country,
3838
+ onClose,
3839
+ onBuy
3840
+ }) {
3841
+ const normalizedCountry = country?.trim().toUpperCase();
3842
+ const topupConfig = normalizedCountry === "IN" ? INR_TOPUP_CONFIG : USD_TOPUP_CONFIG;
3843
+ const minCredits = Math.round(
3844
+ topupConfig.minAmount / topupConfig.pricePerCredit
3845
+ );
3846
+ const maxCredits = Math.round(
3847
+ topupConfig.maxAmount / topupConfig.pricePerCredit
3848
+ );
3849
+ const [credits, setCredits] = useState6(minCredits);
3850
+ const [creditsInput, setCreditsInput] = useState6(String(minCredits));
3851
+ const [priceInput, setPriceInput] = useState6(
3852
+ String(minCredits * topupConfig.pricePerCredit)
3853
+ );
3832
3854
  const [activeField, setActiveField] = useState6("credits");
3833
3855
  const parsedCredits = creditsInput.length ? Number(creditsInput) : credits;
3834
3856
  const previewCredits = Number.isFinite(parsedCredits) ? parsedCredits : credits;
3835
3857
  const pricedCredits = previewCredits > 0 ? previewCredits : 0;
3836
- const price = Number((pricedCredits * PRICE_PER_CREDIT).toFixed(2));
3837
- const isBelowMin = price < MIN_USD;
3838
- const isAboveMax = price > MAX_USD;
3858
+ const price = Number(
3859
+ (pricedCredits * topupConfig.pricePerCredit).toFixed(2)
3860
+ );
3861
+ const isBelowMin = price < topupConfig.minAmount;
3862
+ const isAboveMax = price > topupConfig.maxAmount;
3839
3863
  const isError = isBelowMin || isAboveMax;
3840
3864
  const isInvalid = isError;
3841
3865
  const syncFromCredits = (value) => {
3842
3866
  setCredits(value);
3843
3867
  setCreditsInput(String(value));
3844
- setPriceInput(String(Number((value * PRICE_PER_CREDIT).toFixed(2))));
3868
+ setPriceInput(
3869
+ String(Number((value * topupConfig.pricePerCredit).toFixed(2)))
3870
+ );
3845
3871
  };
3846
- const syncFromPrice = (usd) => {
3847
- const derived = Math.round(usd / PRICE_PER_CREDIT);
3872
+ const syncFromPrice = (amount) => {
3873
+ const derived = Math.round(amount / topupConfig.pricePerCredit);
3848
3874
  setCredits(derived);
3849
3875
  setCreditsInput(String(derived));
3850
- setPriceInput(String(usd));
3876
+ setPriceInput(String(amount));
3851
3877
  };
3852
- const handleDecrement = () => syncFromCredits(Math.max(MIN_CREDITS, credits - STEP));
3853
- const handleIncrement = () => syncFromCredits(Math.min(MAX_CREDITS, credits + STEP));
3878
+ const handleDecrement = () => syncFromCredits(Math.max(minCredits, credits - STEP));
3879
+ const handleIncrement = () => syncFromCredits(Math.min(maxCredits, credits + STEP));
3854
3880
  const handleCreditsChange = (value) => {
3855
3881
  const raw = value.replace(/[^\d]/g, "");
3856
3882
  setCreditsInput(raw);
@@ -3859,7 +3885,9 @@ function BuyCreditsModal({ onClose, onBuy }) {
3859
3885
  const next = Number(raw);
3860
3886
  if (!Number.isNaN(next)) {
3861
3887
  setCredits(next);
3862
- setPriceInput(String(Number((next * PRICE_PER_CREDIT).toFixed(2))));
3888
+ setPriceInput(
3889
+ String(Number((next * topupConfig.pricePerCredit).toFixed(2)))
3890
+ );
3863
3891
  }
3864
3892
  };
3865
3893
  const handleCreditsBlur = () => {
@@ -3877,7 +3905,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
3877
3905
  if (!raw.length) return;
3878
3906
  const next = Number(raw);
3879
3907
  if (!Number.isNaN(next) && next >= 0) {
3880
- const derived = Math.round(next / PRICE_PER_CREDIT);
3908
+ const derived = Math.round(next / topupConfig.pricePerCredit);
3881
3909
  setCredits(derived);
3882
3910
  setCreditsInput(String(derived));
3883
3911
  }
@@ -3981,7 +4009,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
3981
4009
  style: {
3982
4010
  width: 24,
3983
4011
  height: 24,
3984
- opacity: credits <= MIN_CREDITS ? 0.3 : 1,
4012
+ opacity: credits <= minCredits ? 0.3 : 1,
3985
4013
  transition: "opacity 0.15s ease"
3986
4014
  },
3987
4015
  onClick: handleDecrement,
@@ -4039,7 +4067,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
4039
4067
  style: {
4040
4068
  width: 24,
4041
4069
  height: 24,
4042
- opacity: credits >= MAX_CREDITS ? 0.3 : 1,
4070
+ opacity: credits >= maxCredits ? 0.3 : 1,
4043
4071
  transition: "opacity 0.15s ease"
4044
4072
  },
4045
4073
  onClick: handleIncrement,
@@ -4070,7 +4098,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
4070
4098
  lineHeight: "var(--line-height-line-height-lg)",
4071
4099
  color: "var(--alias-text---icons-primary)"
4072
4100
  },
4073
- children: "$"
4101
+ children: currencySymbol
4074
4102
  }
4075
4103
  ),
4076
4104
  /* @__PURE__ */ jsx10(
@@ -4090,7 +4118,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
4090
4118
  onKeyDown: (e) => {
4091
4119
  if (e.key === "Enter") e.currentTarget.blur();
4092
4120
  },
4093
- "aria-label": "Price in USD",
4121
+ "aria-label": "Price",
4094
4122
  style: {
4095
4123
  fontFamily: "var(--font-family-font-family-body)",
4096
4124
  fontSize: "var(--font-size-font-size-lg)",
@@ -4126,7 +4154,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
4126
4154
  lineHeight: "var(--line-height-line-height-sm)",
4127
4155
  color: "var(--alias-text---icons-error)"
4128
4156
  },
4129
- children: isBelowMin ? `Min. ${MIN_CREDITS.toLocaleString()} credits` : `Max. ${MAX_CREDITS.toLocaleString()} credits`
4157
+ children: isBelowMin ? `Min. ${minCredits.toLocaleString()} credits` : `Max. ${maxCredits.toLocaleString()} credits`
4130
4158
  }
4131
4159
  ) })
4132
4160
  }
@@ -4220,6 +4248,9 @@ function formatCurrency(cents, currency) {
4220
4248
  }
4221
4249
  return `$${(cents / 100).toFixed(2)}`;
4222
4250
  }
4251
+ function getCurrencySymbolByCountry(country) {
4252
+ return country?.trim().toUpperCase() === "IN" ? "\u20B9" : "$";
4253
+ }
4223
4254
  function formatCredits(n) {
4224
4255
  return n.toLocaleString("en-US");
4225
4256
  }
@@ -4782,10 +4813,14 @@ function PlansView({
4782
4813
  actionInFlight,
4783
4814
  onPlanAction,
4784
4815
  onCancelDowngrade,
4785
- workspace
4816
+ workspace,
4817
+ isProPlan
4786
4818
  }) {
4787
4819
  console.log("=============", products);
4788
4820
  const { toast } = useSettingsAdapters();
4821
+ const workspaceCurrencySymbol = getCurrencySymbolByCountry(
4822
+ workspace?.country
4823
+ );
4789
4824
  const allPlans = useMemo2(() => {
4790
4825
  if (products.length > 0) {
4791
4826
  return products.flatMap(
@@ -4794,7 +4829,7 @@ function PlansView({
4794
4829
  productId: product.id,
4795
4830
  priceId: price.id,
4796
4831
  planName: price.metadata.name,
4797
- price: price.unit_amount === 0 ? price.currency === "inr" ? "\u20B90" : "$0" : `${formatCurrency(price.unit_amount, price.currency ?? "usd")} / month`,
4832
+ price: price.unit_amount === 0 ? price.currency === "inr" ? "\u20B90" : `${workspaceCurrencySymbol}0` : `${formatCurrency(price.unit_amount, price.currency ?? "usd")} / month`,
4798
4833
  credits: `${Number(price.metadata.credits).toLocaleString()} credits`,
4799
4834
  amount: price.unit_amount,
4800
4835
  currency: price.currency?.toLowerCase(),
@@ -4954,7 +4989,7 @@ function PlansView({
4954
4989
  ScPlanCard,
4955
4990
  {
4956
4991
  planName: freePlan?.planName || "Free",
4957
- price: freePlan?.price || "$0",
4992
+ price: freePlan?.price || `${workspaceCurrencySymbol}0`,
4958
4993
  credits: freePlan?.credits || "3,000 credits",
4959
4994
  type: "free",
4960
4995
  features: getPlanFeatures(freePlan?.amount ?? 0),
@@ -5114,13 +5149,13 @@ function PlansView({
5114
5149
  UpdateSubscriptionModal,
5115
5150
  {
5116
5151
  open: showUpgradeConfirmModal,
5117
- currentPlanName: currentPlan?.planName || "Free",
5118
- currentPlanAmount: currentPlan ? currentPlan.amount === 0 ? "$0" : formatCurrency(currentPlan.amount, currentPlan.currency || "") : "$0",
5152
+ currentPlanName: isProPlan ? "Pro" : currentPlan?.planName || "Free",
5153
+ currentPlanAmount: currentPlan ? currentPlan.amount === 0 ? `${workspaceCurrencySymbol}0` : formatCurrency(currentPlan.amount, currentPlan.currency || "") : `${workspaceCurrencySymbol}0`,
5119
5154
  nextPlanName: selectedMiddlePlan?.planName || "Pro",
5120
- nextPlanAmount: selectedMiddlePlan ? selectedMiddlePlan.amount === 0 ? "$0" : formatCurrency(
5155
+ nextPlanAmount: selectedMiddlePlan ? selectedMiddlePlan.amount === 0 ? `${workspaceCurrencySymbol}0` : formatCurrency(
5121
5156
  selectedMiddlePlan.amount,
5122
5157
  selectedMiddlePlan.currency || ""
5123
- ) : "$0",
5158
+ ) : `${workspaceCurrencySymbol}0`,
5124
5159
  nextBillingDateLabel: formatNextBillingDateLabel(currentPlanEndDate),
5125
5160
  loading: isMiddleActionLoading,
5126
5161
  onClose: () => setShowUpgradeConfirmModal(false),
@@ -5183,9 +5218,11 @@ function BillingTabBar({
5183
5218
  }
5184
5219
  function InvoiceHistoryTable({
5185
5220
  invoices,
5186
- loading
5221
+ loading,
5222
+ workspaceCountry
5187
5223
  }) {
5188
5224
  const { api, toast } = useSettingsAdapters();
5225
+ const currencySymbol = getCurrencySymbolByCountry(workspaceCountry);
5189
5226
  const handleDownload = async (item) => {
5190
5227
  const orderId = item.transactionId;
5191
5228
  if (!orderId) {
@@ -5299,7 +5336,7 @@ function InvoiceHistoryTable({
5299
5336
  ScBillingHistoryTableList,
5300
5337
  {
5301
5338
  invoiceNumber: inv.transactionId ? `# ${inv.transactionId.slice(0, 16).toUpperCase()}` : "# INV-UNKNOWN",
5302
- amount: inv.amountPaid != null ? `$${inv.amountPaid.toFixed(2)}` : `$${(inv.amount / 100).toFixed(2)}`,
5339
+ amount: inv.amountPaid != null ? `${currencySymbol}${inv.amountPaid.toFixed(2)}` : `${currencySymbol}${(inv.amount / 100).toFixed(2)}`,
5303
5340
  date: formatDate(inv.createdAt),
5304
5341
  downloadLabel: "Download invoice",
5305
5342
  onClick: (e) => handleRowClick(e, inv)
@@ -5741,13 +5778,13 @@ function BillingContent({
5741
5778
  setShowInitialLoader(false);
5742
5779
  }, [showInitialLoader, initialFetchTriggered, loadingBilling]);
5743
5780
  console.log("subscription", subscription);
5744
- const isProPlan = products.find(
5781
+ const isProPlan = products.some(
5745
5782
  (product) => product.id == subscription?.stripeProductId && product.name == "Paid"
5746
5783
  );
5747
5784
  console.log("isProPlan", isProPlan);
5748
5785
  const planName = isProPlan ? "Pro" : subscription?.plan?.name?.trim() || (subscription?.plan?.amount ? subscription.plan.amount > 0 ? "Pro" : "Free" : "-");
5749
5786
  const isFreePlan = subscription?.plan?.amount == null || subscription.plan.amount === 0;
5750
- const planAmount = subscription?.plan?.amount != null ? `${subscription?.plan?.currency == "inr" ? "\u20B9" : "$"}${(subscription.plan.amount / 100).toFixed(2)} / ${subscription?.plan?.interval}` : "$0";
5787
+ const planAmount = subscription?.plan?.amount != null ? `${subscription?.plan?.currency == "inr" ? "\u20B9" : "$"}${(subscription.plan.amount / 100).toFixed(2)} / ${subscription?.plan?.interval}` : `${getCurrencySymbolByCountry(workspace.current?.country)}0`;
5751
5788
  const usedCredits = availableCredits != null && totalCredits != null ? Math.max(0, totalCredits - availableCredits) : null;
5752
5789
  const progressPct = usedCredits != null && totalCredits != null && totalCredits > 0 ? Math.min(100, Math.round(usedCredits / totalCredits * 100)) : 0;
5753
5790
  const remainingPct = 100 - progressPct;
@@ -5844,12 +5881,13 @@ function BillingContent({
5844
5881
  }
5845
5882
  );
5846
5883
  try {
5884
+ const topupCurrency = workspace.current?.country?.trim().toUpperCase() === "IN" ? "inr" : "usd";
5847
5885
  const res = await api.buyCredits({
5848
5886
  serviceName: DEFAULT_TOPUP_SERVICE,
5849
5887
  credits,
5850
5888
  unitAmount: price,
5851
5889
  itemCount: 1,
5852
- currency: "usd",
5890
+ currency: topupCurrency,
5853
5891
  successUrl: resolveReturnUrl("success"),
5854
5892
  cancelUrl: resolveReturnUrl("cancel"),
5855
5893
  metadata: { source: "self-serve" }
@@ -5946,7 +5984,8 @@ function BillingContent({
5946
5984
  actionInFlight: planActionInFlight,
5947
5985
  onPlanAction: handlePlanAction,
5948
5986
  onCancelDowngrade: handleCancelDowngrade,
5949
- workspace: workspace.current
5987
+ workspace: workspace.current,
5988
+ isProPlan
5950
5989
  }
5951
5990
  );
5952
5991
  if (embedded) return plansView;
@@ -6037,7 +6076,14 @@ function BillingContent({
6037
6076
  }
6038
6077
  )
6039
6078
  ] }),
6040
- activeTab === "invoice" ? /* @__PURE__ */ jsx11(InvoiceHistoryTable, { invoices, loading: loadingTable }) : /* @__PURE__ */ jsx11(
6079
+ activeTab === "invoice" ? /* @__PURE__ */ jsx11(
6080
+ InvoiceHistoryTable,
6081
+ {
6082
+ invoices,
6083
+ loading: loadingTable,
6084
+ workspaceCountry: workspace.current?.country
6085
+ }
6086
+ ) : /* @__PURE__ */ jsx11(
6041
6087
  UsageLogsTable,
6042
6088
  {
6043
6089
  logs: usageLogs,
@@ -6056,6 +6102,8 @@ function BillingContent({
6056
6102
  showBuyCreditsModal && /* @__PURE__ */ jsx11(
6057
6103
  BuyCreditsModal,
6058
6104
  {
6105
+ country: workspace.current?.country,
6106
+ currencySymbol: getCurrencySymbolByCountry(workspace.current?.country),
6059
6107
  onClose: () => setShowBuyCreditsModal(false),
6060
6108
  onBuy: (credits, price) => {
6061
6109
  handleBuyCredits(credits, price);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamoid/settings",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",